diff --git a/controllers/team_controller.go b/controllers/team_controller.go index c395e83..65a187e 100644 --- a/controllers/team_controller.go +++ b/controllers/team_controller.go @@ -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. diff --git a/controllers/team_controller_test.go b/controllers/team_controller_test.go index c143112..20b7bb0 100644 --- a/controllers/team_controller_test.go +++ b/controllers/team_controller_test.go @@ -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). @@ -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")). @@ -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{