Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,13 @@ describe('appEventsService', () => {
data: expect.objectContaining({ args: payload }),
}))
})

describe('emit surface (migration parity)', () => {
const expectedEmitMethods = ['emitProjectEvent', 'emitProjectMemberEvent', 'emitRepositoryEvent'] as const

it.each(expectedEmitMethods)('exposes %s as a public emit entrypoint', (method) => {
expect(typeof service[method]).toBe('function')
})

})
})
Original file line number Diff line number Diff line change
Expand Up @@ -526,4 +526,28 @@ 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 () => {
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')
})
})
})
Loading