@@ -309,7 +309,19 @@ func TestInstallCertRequirementsForDeployment(t *testing.T) {
309
309
authReaderRoleBinding .SetNamespace (KubeSystem )
310
310
authReaderRoleBinding .SetLabels (map [string ]string {OLMManagedLabelKey : OLMManagedLabelValue })
311
311
312
- mockOpClient .EXPECT ().UpdateRoleBinding (authReaderRoleBinding ).Return (authReaderRoleBinding , nil )
312
+ authReaderRoleBindingApplyConfig := rbacv1ac .RoleBinding (AuthReaderRoleBindingName (service .GetName ()), KubeSystem ).
313
+ WithLabels (map [string ]string {OLMManagedLabelKey : OLMManagedLabelValue }).
314
+ WithSubjects (rbacv1ac .Subject ().
315
+ WithKind ("ServiceAccount" ).
316
+ WithAPIGroup ("" ).
317
+ WithName (args .depSpec .Template .Spec .ServiceAccountName ).
318
+ WithNamespace (namespace )).
319
+ WithRoleRef (rbacv1ac .RoleRef ().
320
+ WithAPIGroup ("rbac.authorization.k8s.io" ).
321
+ WithKind ("Role" ).
322
+ WithName ("extension-apiserver-authentication-reader" ))
323
+
324
+ mockOpClient .EXPECT ().ApplyRoleBinding (authReaderRoleBindingApplyConfig , metav1.ApplyOptions {Force : true , FieldManager : "olm.install" }).Return (authReaderRoleBinding , nil )
313
325
},
314
326
state : fakeState {
315
327
existingService : & corev1.Service {
@@ -569,7 +581,19 @@ func TestInstallCertRequirementsForDeployment(t *testing.T) {
569
581
authReaderRoleBinding .SetNamespace (KubeSystem )
570
582
authReaderRoleBinding .SetLabels (map [string ]string {OLMManagedLabelKey : OLMManagedLabelValue })
571
583
572
- mockOpClient .EXPECT ().UpdateRoleBinding (authReaderRoleBinding ).Return (authReaderRoleBinding , nil )
584
+ authReaderRoleBindingApplyConfig := rbacv1ac .RoleBinding (AuthReaderRoleBindingName (service .GetName ()), KubeSystem ).
585
+ WithLabels (map [string ]string {OLMManagedLabelKey : OLMManagedLabelValue }).
586
+ WithSubjects (rbacv1ac .Subject ().
587
+ WithKind ("ServiceAccount" ).
588
+ WithAPIGroup ("" ).
589
+ WithName (args .depSpec .Template .Spec .ServiceAccountName ).
590
+ WithNamespace (namespace )).
591
+ WithRoleRef (rbacv1ac .RoleRef ().
592
+ WithAPIGroup ("rbac.authorization.k8s.io" ).
593
+ WithKind ("Role" ).
594
+ WithName ("extension-apiserver-authentication-reader" ))
595
+
596
+ mockOpClient .EXPECT ().ApplyRoleBinding (authReaderRoleBindingApplyConfig , metav1.ApplyOptions {Force : true , FieldManager : "olm.install" }).Return (authReaderRoleBinding , nil )
573
597
},
574
598
state : fakeState {
575
599
existingService : & corev1.Service {
@@ -831,7 +855,19 @@ func TestInstallCertRequirementsForDeployment(t *testing.T) {
831
855
authReaderRoleBinding .SetNamespace (KubeSystem )
832
856
authReaderRoleBinding .SetLabels (map [string ]string {OLMManagedLabelKey : OLMManagedLabelValue })
833
857
834
- mockOpClient .EXPECT ().UpdateRoleBinding (authReaderRoleBinding ).Return (authReaderRoleBinding , nil )
858
+ authReaderRoleBindingApplyConfig := rbacv1ac .RoleBinding (AuthReaderRoleBindingName (service .GetName ()), KubeSystem ).
859
+ WithLabels (map [string ]string {OLMManagedLabelKey : OLMManagedLabelValue }).
860
+ WithSubjects (rbacv1ac .Subject ().
861
+ WithKind ("ServiceAccount" ).
862
+ WithAPIGroup ("" ).
863
+ WithName (args .depSpec .Template .Spec .ServiceAccountName ).
864
+ WithNamespace (namespace )).
865
+ WithRoleRef (rbacv1ac .RoleRef ().
866
+ WithAPIGroup ("rbac.authorization.k8s.io" ).
867
+ WithKind ("Role" ).
868
+ WithName ("extension-apiserver-authentication-reader" ))
869
+
870
+ mockOpClient .EXPECT ().ApplyRoleBinding (authReaderRoleBindingApplyConfig , metav1.ApplyOptions {Force : true , FieldManager : "olm.install" }).Return (authReaderRoleBinding , nil )
835
871
},
836
872
state : fakeState {
837
873
existingService : nil ,
0 commit comments