...

Source file src/k8s.io/kubernetes/pkg/kubeapiserver/authorizer/modes/modes_test.go

Documentation: k8s.io/kubernetes/pkg/kubeapiserver/authorizer/modes

     1  /*
     2  Copyright 2017 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package modes
    18  
    19  import "testing"
    20  
    21  func TestIsValidAuthorizationMode(t *testing.T) {
    22  	var tests = []struct {
    23  		authzMode string
    24  		expected  bool
    25  	}{
    26  		{"", false},
    27  		{"rBAC", false},        // not supported
    28  		{"falsy value", false}, // not supported
    29  		{"RBAC", true},         // supported
    30  		{"ABAC", true},         // supported
    31  		{"Webhook", true},      // supported
    32  		{"AlwaysAllow", true},  // supported
    33  		{"AlwaysDeny", true},   // supported
    34  	}
    35  	for _, rt := range tests {
    36  		actual := IsValidAuthorizationMode(rt.authzMode)
    37  		if actual != rt.expected {
    38  			t.Errorf(
    39  				"failed ValidAuthorizationMode:\n\texpected: %t\n\t  actual: %t",
    40  				rt.expected,
    41  				actual,
    42  			)
    43  		}
    44  	}
    45  }
    46  

View as plain text