Check whether static cert is already configured in UpdateTransportConfig

- Also update test-cmd.sh to pass a signing ca to the kube controller
  manager, so CSRs work properly in integration tests.

Signed-off-by: Margo Crawford <margaretc@vmware.com>

Kubernetes-commit: f015fd66ce95d02cd66efc263eb9e5441b42a17d
This commit is contained in:
Margo Crawford 2021-12-07 15:58:46 -08:00 committed by Kubernetes Publisher
parent 0a04e978b0
commit 2b59dabd4c
2 changed files with 10 additions and 3 deletions

View File

@ -290,8 +290,8 @@ func (a *Authenticator) UpdateTransportConfig(c *transport.Config) error {
// also configured to allow client certificates for authentication. For requests // also configured to allow client certificates for authentication. For requests
// like "kubectl get --token (token) pods" we should assume the intention is to // like "kubectl get --token (token) pods" we should assume the intention is to
// use the provided token for authentication. The same can be said for when the // use the provided token for authentication. The same can be said for when the
// user specifies basic auth. // user specifies basic auth or cert auth.
if c.HasTokenAuth() || c.HasBasicAuth() { if c.HasTokenAuth() || c.HasBasicAuth() || c.HasCertAuth() {
return nil return nil
} }
@ -299,7 +299,7 @@ func (a *Authenticator) UpdateTransportConfig(c *transport.Config) error {
return &roundTripper{a, rt} return &roundTripper{a, rt}
}) })
if c.TLS.GetCert != nil { if c.HasCertCallback() {
return errors.New("can't add TLS certificate callback: transport.Config.TLS.GetCert already set") return errors.New("can't add TLS certificate callback: transport.Config.TLS.GetCert already set")
} }
c.TLS.GetCert = a.cert c.TLS.GetCert = a.cert

View File

@ -1206,6 +1206,13 @@ func TestAuthorizationHeaderPresentCancelsExecAction(t *testing.T) {
config.Password = "zelda" config.Password = "zelda"
}, },
}, },
{
name: "cert auth",
setTransportConfig: func(config *transport.Config) {
config.TLS.CertData = []byte("some-cert-data")
config.TLS.KeyData = []byte("some-key-data")
},
},
} }
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {