mirror of
https://github.com/kubernetes/client-go.git
synced 2025-07-07 20:18:44 +00:00
* Kubectl user exec should accept zero-length environment values #652 * Changing TestValidateAuthInfoExecInvalidEnv to allow for empty strings as Exec values Kubernetes-commit: f30af9dd6da46f0f01e38b477d455907da9f1b6c
This commit is contained in:
parent
a9c895e7f2
commit
579ad46bdc
@ -250,8 +250,6 @@ func validateAuthInfo(authInfoName string, authInfo clientcmdapi.AuthInfo) []err
|
|||||||
for _, v := range authInfo.Exec.Env {
|
for _, v := range authInfo.Exec.Env {
|
||||||
if len(v.Name) == 0 {
|
if len(v.Name) == 0 {
|
||||||
validationErrors = append(validationErrors, fmt.Errorf("env variable name must be specified for %v to use exec authentication plugin", authInfoName))
|
validationErrors = append(validationErrors, fmt.Errorf("env variable name must be specified for %v to use exec authentication plugin", authInfoName))
|
||||||
} else if len(v.Value) == 0 {
|
|
||||||
validationErrors = append(validationErrors, fmt.Errorf("env variable %s value must be specified for %v to use exec authentication plugin", v.Name, authInfoName))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -443,22 +443,19 @@ func TestValidateAuthInfoExecWithAuthProvider(t *testing.T) {
|
|||||||
test.testConfig(t)
|
test.testConfig(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestValidateAuthInfoExecInvalidEnv(t *testing.T) {
|
func TestValidateAuthInfoExecNoEnv(t *testing.T) {
|
||||||
config := clientcmdapi.NewConfig()
|
config := clientcmdapi.NewConfig()
|
||||||
config.AuthInfos["user"] = &clientcmdapi.AuthInfo{
|
config.AuthInfos["user"] = &clientcmdapi.AuthInfo{
|
||||||
Exec: &clientcmdapi.ExecConfig{
|
Exec: &clientcmdapi.ExecConfig{
|
||||||
Command: "/bin/example",
|
Command: "/bin/example",
|
||||||
APIVersion: "clientauthentication.k8s.io/v1alpha1",
|
APIVersion: "clientauthentication.k8s.io/v1alpha1",
|
||||||
Env: []clientcmdapi.ExecEnvVar{
|
Env: []clientcmdapi.ExecEnvVar{
|
||||||
{Name: "foo"}, // No value
|
{Name: "foo", Value: ""},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
test := configValidationTest{
|
test := configValidationTest{
|
||||||
config: config,
|
config: config,
|
||||||
expectedErrorSubstring: []string{
|
|
||||||
"env variable foo value must be specified for user to use exec authentication plugin",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
test.testAuthInfo("user", t)
|
test.testAuthInfo("user", t)
|
||||||
|
Loading…
Reference in New Issue
Block a user