@checkstack/auth-backend 0.0.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,7 +17,7 @@ describe("Auth Router", () => {
17
17
  const mockUser = {
18
18
  type: "user" as const,
19
19
  id: "test-user",
20
- permissions: ["*"],
20
+ accessRules: ["*"],
21
21
  roles: ["admin"],
22
22
  } as any;
23
23
 
@@ -69,8 +69,8 @@ describe("Auth Router", () => {
69
69
  list: mock(() => Promise.resolve([])),
70
70
  };
71
71
 
72
- const mockPermissionRegistry = {
73
- getPermissions: () => [
72
+ const mockAccessRuleRegistry = {
73
+ getAccessRules: () => [
74
74
  { id: "auth-backend.users.read", description: "List all users" },
75
75
  { id: "auth-backend.users.manage", description: "Delete users" },
76
76
  { id: "auth-backend.roles.read", description: "Read and list roles" },
@@ -82,13 +82,13 @@ describe("Auth Router", () => {
82
82
  mockRegistry,
83
83
  async () => {},
84
84
  mockConfigService,
85
- mockPermissionRegistry
85
+ mockAccessRuleRegistry
86
86
  );
87
87
 
88
- it("getPermissions returns current user permissions", async () => {
88
+ it("getAccessRules returns current user access rules", async () => {
89
89
  const context = createMockRpcContext({ user: mockUser });
90
- const result = await call(router.permissions, undefined, { context });
91
- expect(result.permissions).toContain("*");
90
+ const result = await call(router.accessRules, undefined, { context });
91
+ expect(result.accessRules).toContain("*");
92
92
  });
93
93
 
94
94
  it("getUsers lists users with roles", async () => {
@@ -145,21 +145,21 @@ describe("Auth Router", () => {
145
145
  expect(deletedTables.includes(schema.user)).toBe(true);
146
146
  });
147
147
 
148
- it("getRoles returns all roles with permissions", async () => {
148
+ it("getRoles returns all roles with accesss", async () => {
149
149
  const context = createMockRpcContext({ user: mockUser });
150
150
  mockDb.select.mockImplementationOnce(() => ({
151
151
  from: mock(() => createChain([{ id: "admin", name: "Admin" }])),
152
152
  }));
153
153
  mockDb.select.mockImplementationOnce(() => ({
154
154
  from: mock(() =>
155
- createChain([{ roleId: "admin", permissionId: "users.manage" }])
155
+ createChain([{ roleId: "admin", accessRuleId: "users.manage" }])
156
156
  ),
157
157
  }));
158
158
 
159
159
  const result = await call(router.getRoles, undefined, { context });
160
160
  expect(result).toHaveLength(1);
161
161
  expect(result[0].id).toBe("admin");
162
- expect(result[0].permissions).toContain("users.manage");
162
+ expect(result[0].accessRules).toContain("users.manage");
163
163
  });
164
164
 
165
165
  it("updateUserRoles updates user roles", async () => {
@@ -214,7 +214,7 @@ describe("Auth Router", () => {
214
214
  expect(result.allowRegistration).toBe(true);
215
215
  });
216
216
 
217
- it("setRegistrationStatus updates flag and requires permission", async () => {
217
+ it("setRegistrationStatus updates flag and requires access", async () => {
218
218
  const context = createMockRpcContext({ user: mockUser });
219
219
  const result = await call(
220
220
  router.setRegistrationStatus,