@@ -839,6 +839,19 @@ func TestNamespaceResolverRBAC(t *testing.T) {
839
839
},
840
840
}
841
841
bundle := bundleWithPermissions ("a.v1" , "a" , "alpha" , "" , nil , nil , nil , nil , simplePermissions , simplePermissions )
842
+ defaultServiceAccountPermissions := []v1alpha1.StrategyDeploymentPermissions {
843
+ {
844
+ ServiceAccountName : "default" ,
845
+ Rules : []rbacv1.PolicyRule {
846
+ {
847
+ Verbs : []string {"get" , "list" },
848
+ APIGroups : []string {"" },
849
+ Resources : []string {"configmaps" },
850
+ },
851
+ },
852
+ },
853
+ }
854
+ bundleWithDefaultServiceAccount := bundleWithPermissions ("a.v1" , "a" , "alpha" , "" , nil , nil , nil , nil , defaultServiceAccountPermissions , defaultServiceAccountPermissions )
842
855
type out struct {
843
856
steps [][]* v1alpha1.Step
844
857
subs []* v1alpha1.Subscription
@@ -865,6 +878,21 @@ func TestNamespaceResolverRBAC(t *testing.T) {
865
878
},
866
879
},
867
880
},
881
+ {
882
+ name : "don't create default service accounts" ,
883
+ clusterState : []runtime.Object {
884
+ newSub (namespace , "a" , "alpha" , catalog ),
885
+ },
886
+ bundlesInCatalog : []* api.Bundle {bundleWithDefaultServiceAccount },
887
+ out : out {
888
+ steps : [][]* v1alpha1.Step {
889
+ withoutResourceKind ("ServiceAccount" , bundleSteps (bundleWithDefaultServiceAccount , namespace , "" , catalog )),
890
+ },
891
+ subs : []* v1alpha1.Subscription {
892
+ updatedSub (namespace , "a.v1" , "" , "a" , "alpha" , catalog ),
893
+ },
894
+ },
895
+ },
868
896
}
869
897
for _ , tt := range tests {
870
898
t .Run (tt .name , func (t * testing.T ) {
@@ -1036,6 +1064,18 @@ func bundleSteps(bundle *api.Bundle, ns, replaces string, catalog registry.Catal
1036
1064
return steps
1037
1065
}
1038
1066
1067
+ func withoutResourceKind (kind string , steps []* v1alpha1.Step ) []* v1alpha1.Step {
1068
+ filtered := make ([]* v1alpha1.Step , 0 )
1069
+
1070
+ for i , s := range steps {
1071
+ if s .Resource .Kind != kind {
1072
+ filtered = append (filtered , steps [i ])
1073
+ }
1074
+ }
1075
+
1076
+ return filtered
1077
+ }
1078
+
1039
1079
func subSteps (namespace , operatorName , pkgName , channelName string , catalog registry.CatalogKey ) []* v1alpha1.Step {
1040
1080
sub := & v1alpha1.Subscription {
1041
1081
ObjectMeta : metav1.ObjectMeta {
0 commit comments