mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-14 05:36:12 +00:00
Add ControllerRoles Test
Added a test to check that if a controller role includes `List`, it also includes `Watch`. Signed-off-by: Mitsuru Kariya <mitsuru.kariya@nttdata.com>
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user