validate nonResourceURL in create clusterrole
This commit is contained in:
@@ -375,6 +375,46 @@ func TestClusterRoleValidate(t *testing.T) {
|
||||
},
|
||||
expectErr: false,
|
||||
},
|
||||
"test-invalid-empty-non-resource-url": {
|
||||
clusterRoleOptions: &CreateClusterRoleOptions{
|
||||
CreateRoleOptions: &CreateRoleOptions{
|
||||
Name: "my-clusterrole",
|
||||
Verbs: []string{"create"},
|
||||
},
|
||||
NonResourceURLs: []string{""},
|
||||
},
|
||||
expectErr: true,
|
||||
},
|
||||
"test-invalid-non-resource-url": {
|
||||
clusterRoleOptions: &CreateClusterRoleOptions{
|
||||
CreateRoleOptions: &CreateRoleOptions{
|
||||
Name: "my-clusterrole",
|
||||
Verbs: []string{"create"},
|
||||
},
|
||||
NonResourceURLs: []string{"logs"},
|
||||
},
|
||||
expectErr: true,
|
||||
},
|
||||
"test-invalid-non-resource-url-with-*": {
|
||||
clusterRoleOptions: &CreateClusterRoleOptions{
|
||||
CreateRoleOptions: &CreateRoleOptions{
|
||||
Name: "my-clusterrole",
|
||||
Verbs: []string{"create"},
|
||||
},
|
||||
NonResourceURLs: []string{"/logs/*/"},
|
||||
},
|
||||
expectErr: true,
|
||||
},
|
||||
"test-invalid-non-resource-url-with-multiple-*": {
|
||||
clusterRoleOptions: &CreateClusterRoleOptions{
|
||||
CreateRoleOptions: &CreateRoleOptions{
|
||||
Name: "my-clusterrole",
|
||||
Verbs: []string{"create"},
|
||||
},
|
||||
NonResourceURLs: []string{"/logs*/*"},
|
||||
},
|
||||
expectErr: true,
|
||||
},
|
||||
"test-invalid-verb-for-non-resource-url": {
|
||||
clusterRoleOptions: &CreateClusterRoleOptions{
|
||||
CreateRoleOptions: &CreateRoleOptions{
|
||||
@@ -397,7 +437,7 @@ func TestClusterRoleValidate(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
NonResourceURLs: []string{"/logs/"},
|
||||
NonResourceURLs: []string{"/logs/", "/logs/*"},
|
||||
},
|
||||
expectErr: false,
|
||||
},
|
||||
|
Reference in New Issue
Block a user