Skip to content
This repository was archived by the owner on Apr 24, 2023. It is now read-only.

Commit 2a031b1

Browse files
committed
fix unit tests - add realmRoles functions
1 parent 3b0fb5a commit 2a031b1

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

pkg/keycloak/realm/phaseHandler_test.go

+41
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,12 @@ func TestPhaseHandlerReconcile(t *testing.T) {
437437
ListUserClientRolesFunc: func(realmName string, clientID string, userID string) (roles []*v1alpha1.KeycloakUserRole, e error) {
438438
return []*v1alpha1.KeycloakUserRole{}, nil
439439
},
440+
ListAvailableUserRealmRolesFunc: func(realmName string, userID string) (roles []*v1alpha1.KeycloakUserRole, e error) {
441+
return []*v1alpha1.KeycloakUserRole{}, nil
442+
},
443+
ListUserRealmRolesFunc: func(realmName string, userID string) (roles []*v1alpha1.KeycloakUserRole, e error) {
444+
return []*v1alpha1.KeycloakUserRole{}, nil
445+
},
440446
FindUserByUsernameFunc: func(name string, realm string) (user *v1alpha1.KeycloakApiUser, e error) {
441447
return &v1alpha1.KeycloakApiUser{}, nil
442448
},
@@ -550,6 +556,12 @@ func TestPhaseHandlerReconcile(t *testing.T) {
550556
ListUserClientRolesFunc: func(realmName string, clientID string, userID string) (roles []*v1alpha1.KeycloakUserRole, e error) {
551557
return []*v1alpha1.KeycloakUserRole{}, nil
552558
},
559+
ListAvailableUserRealmRolesFunc: func(realmName string, userID string) (roles []*v1alpha1.KeycloakUserRole, e error) {
560+
return []*v1alpha1.KeycloakUserRole{}, nil
561+
},
562+
ListUserRealmRolesFunc: func(realmName string, userID string) (roles []*v1alpha1.KeycloakUserRole, e error) {
563+
return []*v1alpha1.KeycloakUserRole{}, nil
564+
},
553565
FindUserByUsernameFunc: func(name string, realm string) (user *v1alpha1.KeycloakApiUser, e error) {
554566
return &v1alpha1.KeycloakApiUser{}, nil
555567
},
@@ -653,6 +665,12 @@ func TestPhaseHandlerReconcile(t *testing.T) {
653665
GetUserFederatedIdentitiesFunc: func(userName string, realmName string) (identities []v1alpha1.FederatedIdentity, e error) {
654666
return []v1alpha1.FederatedIdentity{}, nil
655667
},
668+
ListAvailableUserRealmRolesFunc: func(realmName string, userID string) (roles []*v1alpha1.KeycloakUserRole, e error) {
669+
return []*v1alpha1.KeycloakUserRole{}, nil
670+
},
671+
ListUserRealmRolesFunc: func(realmName string, userID string) (roles []*v1alpha1.KeycloakUserRole, e error) {
672+
return []*v1alpha1.KeycloakUserRole{}, nil
673+
},
656674
ListAuthenticationExecutionsForFlowFunc: listAuthenticationExecutionsForFlowFunc,
657675
}, nil
658676
},
@@ -907,12 +925,29 @@ func TestPhaseHandlerReconcile(t *testing.T) {
907925
},
908926
}, nil
909927
},
928+
ListAvailableUserRealmRolesFunc: func(realmName string, userID string) (roles []*v1alpha1.KeycloakUserRole, e error) {
929+
return []*v1alpha1.KeycloakUserRole{
930+
{
931+
Name: "create-realms",
932+
},
933+
}, nil
934+
},
935+
ListUserRealmRolesFunc: func(realmName string, userID string) (roles []*v1alpha1.KeycloakUserRole, e error) {
936+
return []*v1alpha1.KeycloakUserRole{
937+
{
938+
Name: "delete-this-role",
939+
},
940+
}, nil
941+
},
910942
CreateUserClientRoleFunc: func(role *v1alpha1.KeycloakUserRole, realmName string, clientID string, userId string) error {
911943
return nil
912944
},
913945
DeleteUserClientRoleFunc: func(role *v1alpha1.KeycloakUserRole, realmName string, clientID string, userID string) error {
914946
return nil
915947
},
948+
DeleteUserRealmRoleFunc: func(role *v1alpha1.KeycloakUserRole, realmName string, userID string) error {
949+
return nil
950+
},
916951
FindUserByUsernameFunc: func(name string, realm string) (user *v1alpha1.KeycloakApiUser, e error) {
917952
return &v1alpha1.KeycloakApiUser{}, nil
918953
},
@@ -1021,6 +1056,12 @@ func TestProvisionDeletesPassword(t *testing.T) {
10211056
GetUserFederatedIdentitiesFunc: func(userName string, realmName string) (identities []v1alpha1.FederatedIdentity, e error) {
10221057
return []v1alpha1.FederatedIdentity{}, nil
10231058
},
1059+
ListAvailableUserRealmRolesFunc: func(realmName string, userID string) (roles []*v1alpha1.KeycloakUserRole, e error) {
1060+
return []*v1alpha1.KeycloakUserRole{}, nil
1061+
},
1062+
ListUserRealmRolesFunc: func(realmName string, userID string) (roles []*v1alpha1.KeycloakUserRole, e error) {
1063+
return []*v1alpha1.KeycloakUserRole{}, nil
1064+
},
10241065
ListAuthenticationExecutionsForFlowFunc: listAuthenticationExecutionsForFlowFunc,
10251066
}, nil
10261067
},

0 commit comments

Comments
 (0)