@@ -70,6 +70,7 @@ func TestCollectDeploymentsSnapshot(t *testing.T) {
70
70
"type" : "ReplicaSet" ,
71
71
"IsRunningEnterpriseImage" : false ,
72
72
"externalDomains" : ExternalDomainNone ,
73
+ "customRoles" : CustomRoleNone ,
73
74
"authenticationModeLDAP" : true ,
74
75
"authenticationModeOIDC" : true ,
75
76
"authenticationModeSCRAM" : true ,
@@ -109,6 +110,7 @@ func TestCollectDeploymentsSnapshot(t *testing.T) {
109
110
"type" : "ReplicaSet" ,
110
111
"IsRunningEnterpriseImage" : false ,
111
112
"externalDomains" : ExternalDomainNone ,
113
+ "customRoles" : CustomRoleNone ,
112
114
"authenticationModeSCRAM" : true ,
113
115
"authenticationAgentMode" : util .SCRAM ,
114
116
},
@@ -227,6 +229,7 @@ func TestCollectDeploymentsSnapshot(t *testing.T) {
227
229
"type" : string (mdbv1 .ReplicaSet ),
228
230
"isMultiCluster" : false ,
229
231
"externalDomains" : ExternalDomainNone ,
232
+ "customRoles" : CustomRoleNone ,
230
233
"operatorID" : testOperatorUUID ,
231
234
},
232
235
{
@@ -236,6 +239,7 @@ func TestCollectDeploymentsSnapshot(t *testing.T) {
236
239
"type" : string (mdbv1 .ReplicaSet ),
237
240
"isMultiCluster" : false ,
238
241
"externalDomains" : ExternalDomainNone ,
242
+ "customRoles" : CustomRoleNone ,
239
243
"operatorID" : testOperatorUUID ,
240
244
},
241
245
{
@@ -245,6 +249,7 @@ func TestCollectDeploymentsSnapshot(t *testing.T) {
245
249
"type" : string (mdbv1 .ReplicaSet ),
246
250
"isMultiCluster" : true ,
247
251
"externalDomains" : ExternalDomainNone ,
252
+ "customRoles" : CustomRoleNone ,
248
253
"operatorID" : testOperatorUUID ,
249
254
"databaseClusters" : float64 (0 ),
250
255
},
@@ -255,6 +260,7 @@ func TestCollectDeploymentsSnapshot(t *testing.T) {
255
260
"type" : string (mdbv1 .ReplicaSet ),
256
261
"isMultiCluster" : true ,
257
262
"externalDomains" : ExternalDomainNone ,
263
+ "customRoles" : CustomRoleNone ,
258
264
"operatorID" : testOperatorUUID ,
259
265
"databaseClusters" : float64 (0 ),
260
266
},
@@ -408,6 +414,7 @@ func TestCollectDeploymentsSnapshot(t *testing.T) {
408
414
"operatorID" : testOperatorUUID ,
409
415
"type" : string (mdbv1 .ReplicaSet ),
410
416
"externalDomains" : ExternalDomainNone ,
417
+ "customRoles" : CustomRoleNone ,
411
418
},
412
419
{
413
420
"deploymentUID" : "a31ab7a8-e5bd-480b-afcc-ac2eec9ce348" ,
@@ -418,6 +425,7 @@ func TestCollectDeploymentsSnapshot(t *testing.T) {
418
425
"operatorID" : testOperatorUUID ,
419
426
"type" : string (mdbv1 .ReplicaSet ),
420
427
"externalDomains" : ExternalDomainNone ,
428
+ "customRoles" : CustomRoleNone ,
421
429
},
422
430
{
423
431
"deploymentUID" : "2b138678-4e4c-4be4-9877-16e6eaae279b" ,
@@ -804,6 +812,7 @@ func TestCollectDeploymentsSnapshot(t *testing.T) {
804
812
{
805
813
"deploymentUID" : "2c60ec7b-b233-4d98-97e6-b7c423c19e24" ,
806
814
"externalDomains" : ExternalDomainNone ,
815
+ "customRoles" : CustomRoleNone ,
807
816
"isMultiCluster" : false ,
808
817
"architecture" : string (architectures .NonStatic ),
809
818
"IsRunningEnterpriseImage" : false ,
@@ -813,6 +822,7 @@ func TestCollectDeploymentsSnapshot(t *testing.T) {
813
822
{
814
823
"deploymentUID" : "c7ccb57f-abd1-4944-8a99-02e5a79acf75" ,
815
824
"externalDomains" : ExternalDomainUniform ,
825
+ "customRoles" : CustomRoleNone ,
816
826
"isMultiCluster" : false ,
817
827
"architecture" : string (architectures .NonStatic ),
818
828
"IsRunningEnterpriseImage" : false ,
@@ -822,6 +832,7 @@ func TestCollectDeploymentsSnapshot(t *testing.T) {
822
832
{
823
833
"deploymentUID" : "7eed85ce-7a38-43ea-a338-6d959339c146" ,
824
834
"externalDomains" : ExternalDomainMixed ,
835
+ "customRoles" : CustomRoleNone ,
825
836
"isMultiCluster" : true ,
826
837
"databaseClusters" : float64 (2 ),
827
838
"architecture" : string (architectures .NonStatic ),
@@ -832,6 +843,7 @@ func TestCollectDeploymentsSnapshot(t *testing.T) {
832
843
{
833
844
"deploymentUID" : "584515da-e797-48af-af7f-6561812c15f4" ,
834
845
"externalDomains" : ExternalDomainClusterSpecific ,
846
+ "customRoles" : CustomRoleNone ,
835
847
"isMultiCluster" : true ,
836
848
"databaseClusters" : float64 (2 ),
837
849
"architecture" : string (architectures .NonStatic ),
@@ -842,6 +854,7 @@ func TestCollectDeploymentsSnapshot(t *testing.T) {
842
854
{
843
855
"deploymentUID" : "27b3d7cf-1f8b-434d-a002-ce85f7313507" ,
844
856
"externalDomains" : ExternalDomainNone ,
857
+ "customRoles" : CustomRoleNone ,
845
858
"isMultiCluster" : true ,
846
859
"databaseClusters" : float64 (3 ),
847
860
"architecture" : string (architectures .NonStatic ),
@@ -852,6 +865,7 @@ func TestCollectDeploymentsSnapshot(t *testing.T) {
852
865
{
853
866
"deploymentUID" : "b050040e-7b53-4991-bae4-69663a523804" ,
854
867
"externalDomains" : ExternalDomainUniform ,
868
+ "customRoles" : CustomRoleNone ,
855
869
"isMultiCluster" : true ,
856
870
"databaseClusters" : float64 (3 ),
857
871
"architecture" : string (architectures .NonStatic ),
@@ -862,6 +876,7 @@ func TestCollectDeploymentsSnapshot(t *testing.T) {
862
876
{
863
877
"deploymentUID" : "54427a32-1799-4a1b-b03f-a50484c09d2c" ,
864
878
"externalDomains" : ExternalDomainMixed ,
879
+ "customRoles" : CustomRoleNone ,
865
880
"isMultiCluster" : true ,
866
881
"databaseClusters" : float64 (3 ),
867
882
"architecture" : string (architectures .NonStatic ),
@@ -872,6 +887,7 @@ func TestCollectDeploymentsSnapshot(t *testing.T) {
872
887
{
873
888
"deploymentUID" : "fe6b6fad-51f2-4f98-8ddd-54ae24143ea6" ,
874
889
"externalDomains" : ExternalDomainClusterSpecific ,
890
+ "customRoles" : CustomRoleNone ,
875
891
"isMultiCluster" : true ,
876
892
"databaseClusters" : float64 (3 ),
877
893
"architecture" : string (architectures .NonStatic ),
@@ -921,6 +937,178 @@ func TestCollectDeploymentsSnapshot(t *testing.T) {
921
937
},
922
938
},
923
939
},
940
+ "custom roles test" : {
941
+ objects : []client.Object {
942
+ & mdbv1.MongoDB {
943
+ Spec : mdbv1.MongoDbSpec {
944
+ DbCommonSpec : mdbv1.DbCommonSpec {
945
+ ResourceType : mdbv1 .ReplicaSet ,
946
+ Security : & mdbv1.Security {},
947
+ },
948
+ }, ObjectMeta : metav1.ObjectMeta {
949
+ UID : "be4bacfc-fb41-4e29-b7d1-712460ed908c" ,
950
+ Name : "test-rs-no-roles" ,
951
+ },
952
+ },
953
+ & mdbv1.MongoDB {
954
+ Spec : mdbv1.MongoDbSpec {
955
+ DbCommonSpec : mdbv1.DbCommonSpec {
956
+ ResourceType : mdbv1 .ReplicaSet ,
957
+ Security : & mdbv1.Security {
958
+ Roles : []mdbv1.MongoDBRole {
959
+ {
960
+ Role : "test-role1" ,
961
+ Db : "admin" ,
962
+ Privileges : []mdbv1.Privilege {
963
+ {
964
+ Actions : []string {"action1" , "action2" },
965
+ },
966
+ },
967
+ },
968
+ },
969
+ },
970
+ },
971
+ }, ObjectMeta : metav1.ObjectMeta {
972
+ UID : "c20a7cf1-a12d-4cee-a87e-7f61aa2bd878" ,
973
+ Name : "test-rs-embedded-roles" ,
974
+ },
975
+ },
976
+ & mdbv1.MongoDB {
977
+ Spec : mdbv1.MongoDbSpec {
978
+ DbCommonSpec : mdbv1.DbCommonSpec {
979
+ ResourceType : mdbv1 .ReplicaSet ,
980
+ Security : & mdbv1.Security {
981
+ RoleRefs : []mdbv1.MongoDBRoleRef {
982
+ {
983
+ Name : "test-role" ,
984
+ Kind : "ClusterMongoDBRole" ,
985
+ },
986
+ },
987
+ },
988
+ },
989
+ }, ObjectMeta : metav1.ObjectMeta {
990
+ UID : "97822e48-fb51-4ba5-9993-26841b44a7a3" ,
991
+ Name : "test-rs-ref-roles" ,
992
+ },
993
+ },
994
+ & mdbmulti.MongoDBMultiCluster {
995
+ Spec : mdbmulti.MongoDBMultiSpec {
996
+ DbCommonSpec : mdbv1.DbCommonSpec {
997
+ ResourceType : mdbv1 .ReplicaSet ,
998
+ },
999
+ }, ObjectMeta : metav1.ObjectMeta {
1000
+ UID : "17e352f7-dcd1-4bfa-bc12-a2f4e637477b" ,
1001
+ Name : "test-mrs-no-roles" ,
1002
+ },
1003
+ },
1004
+ & mdbmulti.MongoDBMultiCluster {
1005
+ Spec : mdbmulti.MongoDBMultiSpec {
1006
+ DbCommonSpec : mdbv1.DbCommonSpec {
1007
+ ResourceType : mdbv1 .ReplicaSet ,
1008
+ Security : & mdbv1.Security {
1009
+ Roles : []mdbv1.MongoDBRole {
1010
+ {
1011
+ Role : "test-role1" ,
1012
+ Db : "admin" ,
1013
+ Privileges : []mdbv1.Privilege {
1014
+ {
1015
+ Actions : []string {"action1" , "action2" },
1016
+ },
1017
+ },
1018
+ },
1019
+ },
1020
+ },
1021
+ },
1022
+ }, ObjectMeta : metav1.ObjectMeta {
1023
+ UID : "71368077-ea95-4564-acd6-09ec573fdf61" ,
1024
+ Name : "test-mrs-embedded-roles" ,
1025
+ },
1026
+ },
1027
+ & mdbmulti.MongoDBMultiCluster {
1028
+ Spec : mdbmulti.MongoDBMultiSpec {
1029
+ DbCommonSpec : mdbv1.DbCommonSpec {
1030
+ ResourceType : mdbv1 .ReplicaSet ,
1031
+ Security : & mdbv1.Security {
1032
+ RoleRefs : []mdbv1.MongoDBRoleRef {
1033
+ {
1034
+ Name : "test-role" ,
1035
+ Kind : "ClusterMongoDBRole" ,
1036
+ },
1037
+ },
1038
+ },
1039
+ },
1040
+ }, ObjectMeta : metav1.ObjectMeta {
1041
+ UID : "a8a28c8a-6226-44fc-a8cd-e66a6942ffbd" ,
1042
+ Name : "test-mrs-ref-roles" ,
1043
+ },
1044
+ },
1045
+ },
1046
+ expectedEventsWithProperties : []map [string ]any {
1047
+ {
1048
+ "deploymentUID" : "be4bacfc-fb41-4e29-b7d1-712460ed908c" ,
1049
+ "customRoles" : CustomRoleNone ,
1050
+ "externalDomains" : ExternalDomainNone ,
1051
+ "isMultiCluster" : false ,
1052
+ "architecture" : string (architectures .NonStatic ),
1053
+ "IsRunningEnterpriseImage" : false ,
1054
+ "operatorID" : testOperatorUUID ,
1055
+ "type" : string (mdbv1 .ReplicaSet ),
1056
+ },
1057
+ {
1058
+ "deploymentUID" : "c20a7cf1-a12d-4cee-a87e-7f61aa2bd878" ,
1059
+ "customRoles" : CustomRoleEmbedded ,
1060
+ "externalDomains" : ExternalDomainNone ,
1061
+ "isMultiCluster" : false ,
1062
+ "architecture" : string (architectures .NonStatic ),
1063
+ "IsRunningEnterpriseImage" : false ,
1064
+ "operatorID" : testOperatorUUID ,
1065
+ "type" : string (mdbv1 .ReplicaSet ),
1066
+ },
1067
+ {
1068
+ "deploymentUID" : "97822e48-fb51-4ba5-9993-26841b44a7a3" ,
1069
+ "customRoles" : CustomRoleReferenced ,
1070
+ "externalDomains" : ExternalDomainNone ,
1071
+ "isMultiCluster" : false ,
1072
+ "architecture" : string (architectures .NonStatic ),
1073
+ "IsRunningEnterpriseImage" : false ,
1074
+ "operatorID" : testOperatorUUID ,
1075
+ "type" : string (mdbv1 .ReplicaSet ),
1076
+ },
1077
+ {
1078
+ "deploymentUID" : "17e352f7-dcd1-4bfa-bc12-a2f4e637477b" ,
1079
+ "customRoles" : CustomRoleNone ,
1080
+ "databaseClusters" : float64 (0 ),
1081
+ "externalDomains" : ExternalDomainNone ,
1082
+ "isMultiCluster" : true ,
1083
+ "architecture" : string (architectures .NonStatic ),
1084
+ "IsRunningEnterpriseImage" : false ,
1085
+ "operatorID" : testOperatorUUID ,
1086
+ "type" : string (mdbv1 .ReplicaSet ),
1087
+ },
1088
+ {
1089
+ "deploymentUID" : "71368077-ea95-4564-acd6-09ec573fdf61" ,
1090
+ "customRoles" : CustomRoleEmbedded ,
1091
+ "databaseClusters" : float64 (0 ),
1092
+ "externalDomains" : ExternalDomainNone ,
1093
+ "isMultiCluster" : true ,
1094
+ "architecture" : string (architectures .NonStatic ),
1095
+ "IsRunningEnterpriseImage" : false ,
1096
+ "operatorID" : testOperatorUUID ,
1097
+ "type" : string (mdbv1 .ReplicaSet ),
1098
+ },
1099
+ {
1100
+ "deploymentUID" : "a8a28c8a-6226-44fc-a8cd-e66a6942ffbd" ,
1101
+ "customRoles" : CustomRoleReferenced ,
1102
+ "databaseClusters" : float64 (0 ),
1103
+ "externalDomains" : ExternalDomainNone ,
1104
+ "isMultiCluster" : true ,
1105
+ "architecture" : string (architectures .NonStatic ),
1106
+ "IsRunningEnterpriseImage" : false ,
1107
+ "operatorID" : testOperatorUUID ,
1108
+ "type" : string (mdbv1 .ReplicaSet ),
1109
+ },
1110
+ },
1111
+ },
924
1112
}
925
1113
926
1114
for name , test := range tests {
0 commit comments