@@ -111,19 +111,19 @@ func TestCCOClusterRoleBindingExists(t *testing.T) {
111111func TestCCOClusterRoleBindingSubjects (t * testing.T ) {
112112 bindingPath := filepath .Join ("config" , "rbac" , "clusterrolebinding_cco.yaml" )
113113
114- binding := loadClusterRoleBinding (t , bindingPath )
114+ data , err := os .ReadFile (bindingPath )
115+ require .NoError (t , err , "CCO ClusterRoleBinding should be readable" )
115116
116- expectedSAName := "cluster-cloud-controller-manager-operator"
117+ var binding ClusterRoleBinding
118+ err = yaml .Unmarshal (data , & binding )
119+ require .NoError (t , err , "CCO ClusterRoleBinding should be valid YAML" )
117120
118- found := false
119- for _ , subject := range binding .Subjects {
120- if subject .Kind == "ServiceAccount" && subject .Name == expectedSAName {
121- found = true
122- break
123- }
124- }
121+ require .NotEmpty (t , binding .Subjects , "ClusterRoleBinding should have at least one subject" )
125122
126- assert .Truef (t , found , "expected at least one ServiceAccount subject named %q in ClusterRoleBinding %q" , expectedSAName , binding .Metadata .Name )
123+ assert .Equal (t , "ServiceAccount" , binding .Subjects [0 ].Kind ,
124+ "subject should be a ServiceAccount" )
125+ assert .Equal (t , "rhtpa-operator-controller-manager" , binding .Subjects [0 ].Name ,
126+ "subject should reference the operator's service account" )
127127}
128128
129129func TestCCOResourcesInKustomization (t * testing.T ) {
0 commit comments