feat(orchestration): add v4 additive backend core and policy tests
This commit is contained in:
1 parent
eb17c8e284
commit
e5c83e87fe
18 files changed
+586
-14
No files matched your search
@@ -0,0 +1,24 @@
|
||||
import { ForbiddenException } from "@nestjs/common";
|
||||
import { KillSwitchService } from "./kill-switch.service";
|
||||
|
||||
describe("KillSwitchService", () => {
|
||||
const prisma = { orchestrationKillSwitch: { findUnique: jest.fn() } };
|
||||
const service = new KillSwitchService(prisma as never);
|
||||
|
||||
beforeEach(() => jest.resetAllMocks());
|
||||
|
||||
it.each([
|
||||
["FREEZE_NEW_WORK", "CREATE_TASK"],
|
||||
["STOP_AGENTS", "RUN_AGENT"],
|
||||
["DISABLE_MUTATIONS", "MUTATE_PRODUCTION"],
|
||||
["EMERGENCY_HALT", "OBSERVE"],
|
||||
])("blocks %s at its policy boundary", async (level, action) => {
|
||||
prisma.orchestrationKillSwitch.findUnique.mockResolvedValue({ scope: "GLOBAL", level, active: true });
|
||||
await expect(service.assertAllowed(action as never)).rejects.toThrow(ForbiddenException);
|
||||
});
|
||||
|
||||
it("allows observation while production mutations are disabled", async () => {
|
||||
prisma.orchestrationKillSwitch.findUnique.mockResolvedValue({ scope: "GLOBAL", level: "DISABLE_MUTATIONS", active: true });
|
||||
await expect(service.assertAllowed("OBSERVE")).resolves.toBeUndefined();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user