test(policy): add extreme priority value tests (follow-up to #12617) (#12679)

This commit is contained in:
Allen Hutchison
2025-11-07 09:28:05 -08:00
committed by GitHub
parent 47603ef8e1
commit 5ff7cdc9e8

View File

@@ -394,6 +394,20 @@ priority = -1
expect(error.details).toContain('>= 0');
});
it('should return a schema_validation error if priority is much lower than 0', async () => {
const result = await runLoadPoliciesFromToml(`
[[rule]]
toolName = "test"
decision = "allow"
priority = -9999
`);
expect(result.errors).toHaveLength(1);
const error = result.errors[0];
expect(error.errorType).toBe('schema_validation');
expect(error.details).toContain('priority');
expect(error.details).toContain('>= 0');
});
it('should return a schema_validation error if priority is >= 1000', async () => {
const result = await runLoadPoliciesFromToml(`
[[rule]]
@@ -408,6 +422,20 @@ priority = 1000
expect(error.details).toContain('<= 999');
});
it('should return a schema_validation error if priority is much higher than 1000', async () => {
const result = await runLoadPoliciesFromToml(`
[[rule]]
toolName = "test"
decision = "allow"
priority = 9999
`);
expect(result.errors).toHaveLength(1);
const error = result.errors[0];
expect(error.errorType).toBe('schema_validation');
expect(error.details).toContain('priority');
expect(error.details).toContain('<= 999');
});
it('should return a schema_validation error if decision is invalid', async () => {
const result = await runLoadPoliciesFromToml(`
[[rule]]