mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
moved auth ctx to request context, cleaned up system controller
This commit is contained in:
@@ -16,10 +16,8 @@ describe("authorize", () => {
|
||||
role: "admin"
|
||||
};
|
||||
|
||||
guard.setUserContext(user);
|
||||
|
||||
expect(guard.granted("read")).toBe(true);
|
||||
expect(guard.granted("write")).toBe(true);
|
||||
expect(guard.granted("read", user)).toBe(true);
|
||||
expect(guard.granted("write", user)).toBe(true);
|
||||
|
||||
expect(() => guard.granted("something")).toThrow();
|
||||
});
|
||||
@@ -46,10 +44,8 @@ describe("authorize", () => {
|
||||
role: "admin"
|
||||
};
|
||||
|
||||
guard.setUserContext(user);
|
||||
|
||||
expect(guard.granted("read")).toBe(true);
|
||||
expect(guard.granted("write")).toBe(true);
|
||||
expect(guard.granted("read", user)).toBe(true);
|
||||
expect(guard.granted("write", user)).toBe(true);
|
||||
});
|
||||
|
||||
test("guard implicit allow", async () => {
|
||||
@@ -66,12 +62,12 @@ describe("authorize", () => {
|
||||
}
|
||||
});
|
||||
|
||||
guard.setUserContext({
|
||||
const user = {
|
||||
role: "admin"
|
||||
});
|
||||
};
|
||||
|
||||
expect(guard.granted("read")).toBe(true);
|
||||
expect(guard.granted("write")).toBe(true);
|
||||
expect(guard.granted("read", user)).toBe(true);
|
||||
expect(guard.granted("write", user)).toBe(true);
|
||||
});
|
||||
|
||||
test("guard with guest role implicit allow", async () => {
|
||||
|
||||
Reference in New Issue
Block a user