Skip to content

Commit

Permalink
Updating broken test
Browse files Browse the repository at this point in the history
Signed-off-by: suvaanshkumar <[email protected]>
  • Loading branch information
suvaanshkumar committed Jan 7, 2025
1 parent 8fa0860 commit 1b1d1da
Showing 1 changed file with 8 additions and 38 deletions.
46 changes: 8 additions & 38 deletions pkg/registration/register/aws_irsa/aws_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package aws_irsa

import (
"reflect"
"open-cluster-management.io/ocm/test/integration/util"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -49,32 +49,21 @@ func TestBuildKubeconfig(t *testing.T) {
caData []byte
clientCertFile string
clientKeyFile string
hubClusterArn string
}{
{
name: "without proxy",
server: "https://127.0.0.1:6443",
caData: []byte("fake-ca-bundle"),
clientCertFile: "tls.crt",
clientKeyFile: "tls.key",
},
{
name: "with proxy",
server: "https://127.0.0.1:6443",
caData: []byte("fake-ca-bundle-with-proxy-ca"),
proxyURL: "https://127.0.0.1:3129",
clientCertFile: "tls.crt",
clientKeyFile: "tls.key",
name: "without proxy",
server: "https://127.0.0.1:6443",
hubClusterArn: util.HubClusterArn,
},
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
bootstrapKubeconfig := &clientcmdapi.Config{
Clusters: map[string]*clientcmdapi.Cluster{
"default-cluster": {
Server: c.server,
InsecureSkipTLSVerify: false,
CertificateAuthorityData: c.caData,
ProxyURL: c.proxyURL,
Server: c.server,
InsecureSkipTLSVerify: false,
}},
// Define a context that connects the auth info and cluster, and set it as the default
Contexts: map[string]*clientcmdapi.Context{register.DefaultKubeConfigContext: {
Expand All @@ -92,6 +81,7 @@ func TestBuildKubeconfig(t *testing.T) {
}

registerImpl := &AWSIRSADriver{}
registerImpl.hubClusterArn = c.hubClusterArn
kubeconfig := registerImpl.BuildKubeConfigFromTemplate(bootstrapKubeconfig)
currentContext, ok := kubeconfig.Contexts[kubeconfig.CurrentContext]
if !ok {
Expand All @@ -107,26 +97,6 @@ func TestBuildKubeconfig(t *testing.T) {
t.Errorf("expected server %q, but got %q", c.server, cluster.Server)
}

if cluster.ProxyURL != c.proxyURL {
t.Errorf("expected proxy URL %q, but got %q", c.proxyURL, cluster.ProxyURL)
}

if !reflect.DeepEqual(cluster.CertificateAuthorityData, c.caData) {
t.Errorf("expected ca data %v, but got %v", c.caData, cluster.CertificateAuthorityData)
}

authInfo, ok := kubeconfig.AuthInfos[currentContext.AuthInfo]
if !ok {
t.Errorf("auth info %q not found: %v", currentContext.AuthInfo, kubeconfig)
}

if authInfo.ClientCertificate != c.clientCertFile {
t.Errorf("expected client certificate %q, but got %q", c.clientCertFile, authInfo.ClientCertificate)
}

if authInfo.ClientKey != c.clientKeyFile {
t.Errorf("expected client key %q, but got %q", c.clientKeyFile, authInfo.ClientKey)
}
})
}
}

0 comments on commit 1b1d1da

Please sign in to comment.