Skip to content

Commit

Permalink
Fix teams synced as top-level organization (#59)
Browse files Browse the repository at this point in the history
#57 changed the `keycloak.NewGroup` signature to take the first argument as the display name. The teams controller was forgotten. The organization of the team was used as the display name and removed from the path. This made the team look like an organization after syncing them to Keycloak.
  • Loading branch information
bastjan authored Oct 12, 2023
1 parent 81537bb commit c297733
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion controllers/team_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func buildTeamKeycloakGroup(team *controlv1.Team) keycloak.Group {
groupMem = append(groupMem, u.Name)
}

return keycloak.NewGroup(team.Namespace, team.Name).WithMemberNames(groupMem...)
return keycloak.NewGroup(team.Spec.DisplayName, team.Namespace, team.Name).WithMemberNames(groupMem...)
}

// SetupWithManager sets up the controller with the Manager.
Expand Down
6 changes: 3 additions & 3 deletions controllers/team_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func Test_TeamController_Reconcile_Success(t *testing.T) {
ctx := context.Background()

c, keyMock, _ := prepareTest(t, barTeam)
group := keycloak.NewGroup(barTeam.Namespace, barTeam.Name).WithMemberNames("baz", "qux")
group := keycloak.NewGroup(barTeam.Spec.DisplayName, barTeam.Namespace, barTeam.Name).WithMemberNames("baz", "qux")
keyMock.EXPECT().
PutGroup(gomock.Any(), group).
Return(group, nil).
Expand Down Expand Up @@ -50,7 +50,7 @@ func Test_TeamController_Reconcile_Failure(t *testing.T) {
ctx := context.Background()

c, keyMock, erMock := prepareTest(t, barTeam)
group := keycloak.NewGroup(barTeam.Namespace, barTeam.Name).WithMemberNames("baz", "qux")
group := keycloak.NewGroup(barTeam.Spec.DisplayName, barTeam.Namespace, barTeam.Name).WithMemberNames("baz", "qux")
keyMock.EXPECT().
PutGroup(gomock.Any(), group).
Return(keycloak.Group{}, errors.New("create failed")).
Expand Down Expand Up @@ -83,7 +83,7 @@ func Test_TeamController_Reconcile_Member_Failure(t *testing.T) {
ctx := context.Background()

c, keyMock, erMock := prepareTest(t, barTeam)
group := keycloak.NewGroup(barTeam.Namespace, barTeam.Name).WithMemberNames("baz", "qux")
group := keycloak.NewGroup(barTeam.Spec.DisplayName, barTeam.Namespace, barTeam.Name).WithMemberNames("baz", "qux")
keyMock.EXPECT().
PutGroup(gomock.Any(), group).
Return(keycloak.Group{}, &keycloak.MembershipSyncErrors{
Expand Down

0 comments on commit c297733

Please sign in to comment.