-
Notifications
You must be signed in to change notification settings - Fork 8
test(server-nestjs): parité reconcile-only des rôles admin keycloak + garde d'émission #2581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -526,4 +526,34 @@ describe('keycloakService', () => { | |
| expect(keycloak.removeUserFromGroup).toHaveBeenCalledWith('user-2', 'system-managed-id') | ||
| }) | ||
| }) | ||
|
|
||
| describe('migration parity: admin-role event path (legacy hook.adminRole.*)', () => { | ||
| const adminRoles: AdminRoleWithDetails[] = [ | ||
| { id: 'admin-role-1', name: 'admin', permissions: 0n, position: 0, oidcGroup: '/admin-group', type: 'managed' }, | ||
| ] | ||
| const users: UserWithAdminRoles[] = [ | ||
| { id: 'user-1', adminRoleIds: ['admin-role-1'] }, | ||
| ] | ||
|
|
||
| it('syncs admin-role OIDC groups via cron reconcile ONLY (no event path exists)', async () => { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 risk: Le test de « parité » n'assert que
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔵 nit: Doublon de « should sync admin role groups » (L82) : même flux handleCron, seuls les ids changent. La valeur ajoutée est le nom, pas la couverture — fusionner dans le test existant ou supprimer. |
||
| datastore.getAllProjects.mockResolvedValue([]) | ||
| datastore.getAllAdminRoles.mockResolvedValue(adminRoles) | ||
| datastore.getAllUsersWithAdminRoleIds.mockResolvedValue(users) | ||
|
|
||
| const adminGroup = makeGroupRepresentation({ id: 'kc-parity-group-id', name: 'admin', path: '/console/parity-admin' }) | ||
| keycloak.getOrCreateGroupByPath.mockResolvedValue(adminGroup) | ||
| keycloak.getGroupMembers.mockResolvedValue([]) | ||
|
|
||
| await service.handleCron() | ||
|
|
||
| expect(keycloak.getOrCreateGroupByPath).toHaveBeenCalledWith('/admin-group') | ||
| expect(keycloak.addUserToGroup).toHaveBeenCalledWith('user-1', 'kc-parity-group-id') | ||
| }) | ||
|
|
||
| it('exposes NO adminRole emit entrypoint on AppEventsService (cutover guard)', async () => { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔵 nit: La garde emitAdminRoleEvent vit dans le spec keycloak avec un import dynamique + |
||
| const { AppEventsService } = await import('../events/app-events.service') | ||
| expect(Object.getOwnPropertyNames(AppEventsService.prototype)) | ||
| .not.toContain('emitAdminRoleEvent') | ||
| }) | ||
| }) | ||
| }) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[✨ Éloge] Les gardes négatives documentées (« pas d'emitAdminRoleEvent ») transforment un choix de migration en contrat testé — bon filet anti-régression pour le cutover.