Merge pull request #607 from mattmoyer/fix-eks-nested-impersonation-tests

Fix TestImpersonationProxy on EKS.
This commit is contained in:
Matt Moyer 2021-05-07 16:46:40 -05:00 committed by GitHub
commit 9fc7f43245
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1705,17 +1705,18 @@ func getCredForConfig(t *testing.T, config *rest.Config) *loginv1alpha1.ClusterC
if tlsConfig != nil && tlsConfig.GetClientCertificate != nil { if tlsConfig != nil && tlsConfig.GetClientCertificate != nil {
cert, err := tlsConfig.GetClientCertificate(nil) cert, err := tlsConfig.GetClientCertificate(nil)
require.NoError(t, err) require.NoError(t, err)
require.Len(t, cert.Certificate, 1) if len(cert.Certificate) > 0 {
require.Len(t, cert.Certificate, 1)
publicKey := pem.EncodeToMemory(&pem.Block{
Type: "CERTIFICATE",
Bytes: cert.Certificate[0],
})
out.ClientCertificateData = string(publicKey)
publicKey := pem.EncodeToMemory(&pem.Block{ privateKey, err := keyutil.MarshalPrivateKeyToPEM(cert.PrivateKey)
Type: "CERTIFICATE", require.NoError(t, err)
Bytes: cert.Certificate[0], out.ClientKeyData = string(privateKey)
}) }
out.ClientCertificateData = string(publicKey)
privateKey, err := keyutil.MarshalPrivateKeyToPEM(cert.PrivateKey)
require.NoError(t, err)
out.ClientKeyData = string(privateKey)
} }
if *out == (loginv1alpha1.ClusterCredential{}) { if *out == (loginv1alpha1.ClusterCredential{}) {