Skip to content

Commit d2bdab2

Browse files
os-salesclaude
andauthored
test(plugin-auth): register the production object set in the two SCIM harnesses (#14751)
Both SCIM harnesses re-spelled plugin-auth's object set by hand and omitted every OAuth object, so the oauth-provider's `session.delete.before` hook — which reads `sys_oauth_access_token` and `sys_oauth_refresh_token` by `sessionId` on every session revocation — hit tables that were never created and logged a Better Auth ERROR on a green run. Import `authIdentityObjects` from the plugin's own manifest instead of re-spelling it. That is the same array `auth-plugin.ts` registers at runtime and `objectstack.config.ts` declares at compile time, so the harness cannot drift from a real deployment by construction. Claude-Session: https://claude.ai/code/session_01AUF1NoViznQK32gqpK8wS8 Co-authored-by: Claude <noreply@anthropic.com>
1 parent 89a156a commit d2bdab2

2 files changed

Lines changed: 19 additions & 81 deletions

File tree

packages/plugins/plugin-auth/src/scim-deactivation-reconcile-user.test.ts

Lines changed: 12 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -61,27 +61,8 @@ import { describe, it, expect, afterEach } from 'vitest';
6161
import { ObjectQL } from '@objectstack/objectql';
6262
import { SqlDriver } from '@objectstack/driver-sql';
6363
import { ADMIN_FULL_ACCESS } from '@objectstack/spec/identity';
64-
import {
65-
SysUser,
66-
SysSession,
67-
SysAccount,
68-
SysVerification,
69-
SysOrganization,
70-
SysMember,
71-
SysInvitation,
72-
SysTeam,
73-
SysTeamMember,
74-
SysScimConnectionBinding,
75-
SysScimConnectionCredential,
76-
SysScimGroup,
77-
SysScimGroupMember,
78-
SysScimIdentityTombstone,
79-
SysScimProjectionGrant,
80-
SysScimSubject,
81-
SysScimUser,
82-
SysJwks,
83-
} from '@objectstack/platform-objects';
8464
import { AuthManager } from './auth-manager.js';
65+
import { authIdentityObjects } from './manifest.js';
8566
import { createTenancyService } from './tenancy-service.js';
8667
import { mintScimConnectionCredential } from './scim-connection-service.js';
8768
import { registerLastAdminGuard, type LastAdminGuardEngine } from './last-admin-guard.js';
@@ -102,27 +83,17 @@ const SCIM_ERROR_SCHEMA = 'urn:ietf:params:scim:api:messages:2.0:Error';
10283
/** Every read below is a safety-proof read, never RLS-scoped to a caller. */
10384
const SYSTEM = { context: { isSystem: true } } as const;
10485

105-
/** The identity surface the org + admin (forced by SCIM) + scim plugins touch. */
106-
const AUTH_OBJECTS = [
107-
SysUser,
108-
SysSession,
109-
SysAccount,
110-
SysVerification,
111-
SysOrganization,
112-
SysMember,
113-
SysInvitation,
114-
SysTeam,
115-
SysTeamMember,
116-
SysScimConnectionBinding,
117-
SysScimConnectionCredential,
118-
SysScimGroup,
119-
SysScimGroupMember,
120-
SysScimIdentityTombstone,
121-
SysScimProjectionGrant,
122-
SysScimSubject,
123-
SysScimUser,
124-
SysJwks,
125-
];
86+
/**
87+
* The objects a deployment that mounts plugin-auth registers, imported from the
88+
* plugin's own manifest rather than re-spelled here, so this harness cannot
89+
* drift from what `auth-plugin.ts` registers at runtime (#14615). The
90+
* hand-written list this replaced omitted the OAuth objects, and the
91+
* oauth-provider's `session.delete.before` hook reads two of them
92+
* (`sys_oauth_access_token`, `sys_oauth_refresh_token`) on every session
93+
* revocation — which made every revocation this suite drives log a Better Auth
94+
* ERROR about a missing table.
95+
*/
96+
const AUTH_OBJECTS = authIdentityObjects;
12697

12798
/**
12899
* The two tables the break-glass guard enumerates platform administrators

packages/plugins/plugin-auth/src/scim-transaction-scope.test.ts

Lines changed: 7 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -54,27 +54,8 @@
5454
import { describe, it, expect, afterEach, vi } from 'vitest';
5555
import { ObjectQL } from '@objectstack/objectql';
5656
import { SqlDriver } from '@objectstack/driver-sql';
57-
import {
58-
SysUser,
59-
SysSession,
60-
SysAccount,
61-
SysVerification,
62-
SysOrganization,
63-
SysMember,
64-
SysInvitation,
65-
SysTeam,
66-
SysTeamMember,
67-
SysScimConnectionBinding,
68-
SysScimConnectionCredential,
69-
SysScimGroup,
70-
SysScimGroupMember,
71-
SysScimIdentityTombstone,
72-
SysScimProjectionGrant,
73-
SysScimSubject,
74-
SysScimUser,
75-
SysJwks,
76-
} from '@objectstack/platform-objects';
7757
import { AuthManager } from './auth-manager.js';
58+
import { authIdentityObjects } from './manifest.js';
7859
import { createTenancyService } from './tenancy-service.js';
7960
import { inScimRequestScope, mintScimConnectionCredential } from './scim-connection-service.js';
8061

@@ -92,26 +73,12 @@ const SYSTEM = { context: { isSystem: true } } as const;
9273
/** The identity objects a SCIM provisioning request touches. */
9374
const IDENTITY_OBJECTS = ['sys_user', 'sys_scim_subject', 'sys_scim_user'] as const;
9475

95-
const AUTH_OBJECTS = [
96-
SysUser,
97-
SysSession,
98-
SysAccount,
99-
SysVerification,
100-
SysOrganization,
101-
SysMember,
102-
SysInvitation,
103-
SysTeam,
104-
SysTeamMember,
105-
SysScimConnectionBinding,
106-
SysScimConnectionCredential,
107-
SysScimGroup,
108-
SysScimGroupMember,
109-
SysScimIdentityTombstone,
110-
SysScimProjectionGrant,
111-
SysScimSubject,
112-
SysScimUser,
113-
SysJwks,
114-
];
76+
/**
77+
* The objects a deployment that mounts plugin-auth registers, imported from the
78+
* plugin's own manifest rather than re-spelled here, so this harness cannot
79+
* drift from what `auth-plugin.ts` registers at runtime (#14615).
80+
*/
81+
const AUTH_OBJECTS = authIdentityObjects;
11582

11683
const engines: ObjectQL[] = [];
11784
afterEach(async () => {

0 commit comments

Comments
 (0)