diff --git a/plugin/pkg/auth/authorizer/rbac/bootstrappolicy/controller_policy_test.go b/plugin/pkg/auth/authorizer/rbac/bootstrappolicy/controller_policy_test.go index 365b5c3d20d..75bbff2e151 100644 --- a/plugin/pkg/auth/authorizer/rbac/bootstrappolicy/controller_policy_test.go +++ b/plugin/pkg/auth/authorizer/rbac/bootstrappolicy/controller_policy_test.go @@ -18,6 +18,7 @@ package bootstrappolicy import ( "reflect" + "slices" "testing" "k8s.io/apimachinery/pkg/api/meta" @@ -91,3 +92,15 @@ func TestControllerRoleLabel(t *testing.T) { } } } + +func TestControllerRoleVerbsConsistensy(t *testing.T) { + roles := ControllerRoles() + for _, role := range roles { + for _, rule := range role.Rules { + verbs := rule.Verbs + if slices.Contains(verbs, "list") && !slices.Contains(verbs, "watch") { + t.Errorf("The ClusterRole %s has Verb `List` but does not have Verb `Watch`.", role.Name) + } + } + } +}