Skip to content

Commit 191abed

Browse files
committed
Added tests
Signed-off-by: desmax74 <mdessi@redhat.com>
1 parent 91a24c9 commit 191abed

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

test/integration/cco_rbac_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,19 +111,19 @@ func TestCCOClusterRoleBindingExists(t *testing.T) {
111111
func 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

129129
func TestCCOResourcesInKustomization(t *testing.T) {

0 commit comments

Comments
 (0)