Skip to content
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

fix: fail on request errors for triggering retry #143

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
2acee7f
fix: fail on request errors for triggering retry
merll Nov 18, 2024
4ddd334
fix: deduplicate redirect URLs
merll Nov 18, 2024
c3d9c29
chore: removed unused code
merll Nov 21, 2024
c8f92c7
fix: avoid failure if group does not exist
merll Nov 22, 2024
9e3a630
fix: added typed user representation
merll Nov 22, 2024
33dc315
fix: check for difference before updating realm, client, users
merll Nov 22, 2024
b6c76ff
fix: updated test with new function call
merll Nov 22, 2024
a496f36
fix: linter errors
merll Nov 22, 2024
adf0b7d
fix: include groups in comparison
merll Nov 22, 2024
eaaf951
fix: group list editing
merll Nov 22, 2024
f60f742
feat: added logging for missing groups
merll Nov 22, 2024
a6e0116
fix: groups are not part of user endpoint
merll Nov 22, 2024
bea015a
fix: function argument in test
merll Nov 22, 2024
ce5ea5d
fix: revised user group assignment
merll Nov 25, 2024
17837a6
fix: work with one connection, one api
merll Nov 25, 2024
784bc6e
fix: check for existing names
merll Nov 25, 2024
a9195ef
feat: some rewrite to improve logging
merll Nov 25, 2024
68374fd
chore: remove extra function call
merll Nov 25, 2024
43d3c1d
fix: linter
merll Nov 25, 2024
6f2953d
fix: update call in test
merll Nov 25, 2024
8203505
fix: log user email instead of username
merll Nov 25, 2024
d02c1ec
fix: avoid potential race condition in role / group creation
merll Nov 25, 2024
b691756
fix: array comparison
merll Nov 25, 2024
8f8c17c
fix: stringify objects in error message
merll Nov 25, 2024
0d9762a
fix: linter
merll Nov 25, 2024
ba267a6
fix: call requires 404 error handling
merll Nov 25, 2024
0a81a17
fix: include tests in root src
merll Nov 26, 2024
ca63c43
feat: added tests for update check
merll Nov 26, 2024
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
"operator:harbor": "node dist/operator/harbor.js",
"operator:keycloak-dev": "NODE_TLS_REJECT_UNAUTHORIZED=0 ts-node-dev ./src/operator/keycloak.ts",
"operator:keycloak": "node dist/operator/keycloak.js",
"test": "NODE_ENV=test mocha -r ts-node/register -r ts-custom-error --exit src/**/*.test.*"
"test": "NODE_ENV=test mocha -r ts-node/register -r ts-custom-error --exit src/*.test.* src/**/*.test.*"
},
"standard-version": {
"skip": {
Expand Down
19 changes: 11 additions & 8 deletions src/operator/keycloak.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai'
import sinon from 'sinon'
import { addUserGroups, removeUserGroups } from './keycloak'
import { updateUserGroups } from './keycloak'

describe('Keycloak User Group Management', () => {
let api: any
Expand Down Expand Up @@ -28,13 +28,17 @@ describe('Keycloak User Group Management', () => {

describe('removeUserGroups', () => {
it('should remove user from groups not in teamGroups', async () => {
const groupsById = {
group1: 'group1-id',
group2: 'group2-id',
}
const existingUserGroups = [
{ name: 'group1', id: 'group1-id' },
{ name: 'group2', id: 'group2-id' },
]
api.users.realmUsersIdGroupsGet.resolves({ body: existingUserGroups })

await removeUserGroups(api, existingUser, ['group1'])
await updateUserGroups(api, existingUser, groupsById, ['group1'])

expect(api.users.realmUsersIdGroupsGroupIdDelete.calledWith(keycloakRealm, 'user-id', 'group2-id')).to.be.true
expect(api.users.realmUsersIdGroupsGroupIdDelete.calledWith(keycloakRealm, 'user-id', 'group1-id')).to.be.false
Expand All @@ -43,15 +47,14 @@ describe('Keycloak User Group Management', () => {

describe('addUserGroups', () => {
it('should add user to groups in teamGroups if not already present', async () => {
const currentKeycloakGroups = [
{ name: 'group1', id: 'group1-id' },
{ name: 'group2', id: 'group2-id' },
]
const groupsById = {
group1: 'group1-id',
group2: 'group2-id',
}
const existingUserGroups = [{ name: 'group1', id: 'group1-id' }]
api.groups.realmGroupsGet.resolves({ body: currentKeycloakGroups })
api.users.realmUsersIdGroupsGet.resolves({ body: existingUserGroups })

await addUserGroups(api, existingUser, ['group1', 'group2'])
await updateUserGroups(api, existingUser, groupsById, ['group1', 'group2'])

expect(api.users.realmUsersIdGroupsGroupIdPut.calledWith(keycloakRealm, 'user-id', 'group2-id')).to.be.true
expect(api.users.realmUsersIdGroupsGroupIdPut.calledWith(keycloakRealm, 'user-id', 'group1-id')).to.be.false
Expand Down
Loading