From 579ad46bdcb9f824edd6ecc0af919cc3aa7acd83 Mon Sep 17 00:00:00 2001 From: Peter Swica Date: Thu, 25 Jul 2019 19:01:41 -0400 Subject: [PATCH] Kubectl user exec should accept zero-length environment values #652 (#78875) * Kubectl user exec should accept zero-length environment values #652 * Changing TestValidateAuthInfoExecInvalidEnv to allow for empty strings as Exec values Kubernetes-commit: f30af9dd6da46f0f01e38b477d455907da9f1b6c --- tools/clientcmd/validation.go | 2 -- tools/clientcmd/validation_test.go | 7 ++----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/tools/clientcmd/validation.go b/tools/clientcmd/validation.go index 629c0b30..720d0b88 100644 --- a/tools/clientcmd/validation.go +++ b/tools/clientcmd/validation.go @@ -250,8 +250,6 @@ func validateAuthInfo(authInfoName string, authInfo clientcmdapi.AuthInfo) []err for _, v := range authInfo.Exec.Env { if len(v.Name) == 0 { 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)) } } } diff --git a/tools/clientcmd/validation_test.go b/tools/clientcmd/validation_test.go index 4742b1a1..1680eeb1 100644 --- a/tools/clientcmd/validation_test.go +++ b/tools/clientcmd/validation_test.go @@ -443,22 +443,19 @@ func TestValidateAuthInfoExecWithAuthProvider(t *testing.T) { test.testConfig(t) } -func TestValidateAuthInfoExecInvalidEnv(t *testing.T) { +func TestValidateAuthInfoExecNoEnv(t *testing.T) { config := clientcmdapi.NewConfig() config.AuthInfos["user"] = &clientcmdapi.AuthInfo{ Exec: &clientcmdapi.ExecConfig{ Command: "/bin/example", APIVersion: "clientauthentication.k8s.io/v1alpha1", Env: []clientcmdapi.ExecEnvVar{ - {Name: "foo"}, // No value + {Name: "foo", Value: ""}, }, }, } test := configValidationTest{ config: config, - expectedErrorSubstring: []string{ - "env variable foo value must be specified for user to use exec authentication plugin", - }, } test.testAuthInfo("user", t)