diff --git a/packages/core/src/policy/toml-loader.test.ts b/packages/core/src/policy/toml-loader.test.ts index 0161bf6af1..77b44bc2ca 100644 --- a/packages/core/src/policy/toml-loader.test.ts +++ b/packages/core/src/policy/toml-loader.test.ts @@ -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]]