Skip to content

Commit

Permalink
Grant ns admin missing create RBAC for various CDI resources (#3031)
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>
Co-authored-by: Alex Kalenyuk <akalenyu@redhat.com>
  • Loading branch information
kubevirt-bot and akalenyu committed Dec 14, 2023
1 parent 8ab775d commit 0dfa4e0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
5 changes: 5 additions & 0 deletions pkg/operator/resources/cluster/rbac.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ func getAdminPolicyRules() []rbacv1.PolicyRule {
},
Resources: []string{
"datavolumes",
"dataimportcrons",
"datasources",
"volumeimportsources",
"volumeuploadsources",
"volumeclonesources",
},
Verbs: []string{
"*",
Expand Down
18 changes: 6 additions & 12 deletions tests/rbac_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package tests

import (
"context"
"fmt"
"reflect"
"time"

. "github.com/onsi/ginkgo/v2"
Expand Down Expand Up @@ -217,6 +215,11 @@ var _ = Describe("Aggregated role definition tests", func() {
},
Resources: []string{
"datavolumes",
"dataimportcrons",
"datasources",
"volumeimportsources",
"volumeuploadsources",
"volumeclonesources",
},
Verbs: []string{
"*",
Expand Down Expand Up @@ -289,16 +292,7 @@ var _ = Describe("Aggregated role definition tests", func() {
clusterRole, err := f.K8sClient.RbacV1().ClusterRoles().Get(context.TODO(), role, metav1.GetOptions{})
Expect(err).ToNot(HaveOccurred())

for _, expectedRule := range rules {
found := false
for _, r := range clusterRole.Rules {
if reflect.DeepEqual(expectedRule, r) {
found = true
break
}
}
Expect(found).To(BeTrue(), fmt.Sprintf("Rule for resources %v should exist", expectedRule.Resources))
}
Expect(clusterRole.Rules).To(ContainElements(rules))
},
Entry("[test_id:3945]for admin", "admin", adminRules),
Entry("[test_id:3946]for edit", "edit", editRules),
Expand Down

0 comments on commit 0dfa4e0

Please sign in to comment.