Switch TestImpersonationProxy to get clients from library.NewKubeclient instead of directly from kubernetes.NewForConfig.
Signed-off-by: Matt Moyer <moyerm@vmware.com>
This commit is contained in:
parent
8fd6a71312
commit
a58b460bcb
@ -73,7 +73,7 @@ func TestImpersonationProxy(t *testing.T) {
|
|||||||
return &config
|
return &config
|
||||||
}
|
}
|
||||||
|
|
||||||
impersonationProxyViaSquidClient := func(caData []byte, doubleImpersonateUser string) *kubernetes.Clientset {
|
impersonationProxyViaSquidClient := func(caData []byte, doubleImpersonateUser string) kubernetes.Interface {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
kubeconfig := impersonationProxyRestConfig("https://"+proxyServiceEndpoint, caData, doubleImpersonateUser)
|
kubeconfig := impersonationProxyRestConfig("https://"+proxyServiceEndpoint, caData, doubleImpersonateUser)
|
||||||
kubeconfig.Proxy = func(req *http.Request) (*url.URL, error) {
|
kubeconfig.Proxy = func(req *http.Request) (*url.URL, error) {
|
||||||
@ -82,17 +82,13 @@ func TestImpersonationProxy(t *testing.T) {
|
|||||||
t.Logf("passing request for %s through proxy %s", req.URL, proxyURL.String())
|
t.Logf("passing request for %s through proxy %s", req.URL, proxyURL.String())
|
||||||
return proxyURL, nil
|
return proxyURL, nil
|
||||||
}
|
}
|
||||||
impersonationProxyClient, err := kubernetes.NewForConfig(kubeconfig)
|
return library.NewKubeclient(t, kubeconfig).Kubernetes
|
||||||
require.NoError(t, err, "unexpected failure from kubernetes.NewForConfig()")
|
|
||||||
return impersonationProxyClient
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impersonationProxyViaLoadBalancerClient := func(proxyURL string, caData []byte, doubleImpersonateUser string) *kubernetes.Clientset {
|
impersonationProxyViaLoadBalancerClient := func(proxyURL string, caData []byte, doubleImpersonateUser string) kubernetes.Interface {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
kubeconfig := impersonationProxyRestConfig(proxyURL, caData, doubleImpersonateUser)
|
kubeconfig := impersonationProxyRestConfig(proxyURL, caData, doubleImpersonateUser)
|
||||||
impersonationProxyClient, err := kubernetes.NewForConfig(kubeconfig)
|
return library.NewKubeclient(t, kubeconfig).Kubernetes
|
||||||
require.NoError(t, err, "unexpected failure from kubernetes.NewForConfig()")
|
|
||||||
return impersonationProxyClient
|
|
||||||
}
|
}
|
||||||
|
|
||||||
oldConfigMap, err := adminClient.CoreV1().ConfigMaps(env.ConciergeNamespace).Get(ctx, impersonationProxyConfigMapName(env), metav1.GetOptions{})
|
oldConfigMap, err := adminClient.CoreV1().ConfigMaps(env.ConciergeNamespace).Get(ctx, impersonationProxyConfigMapName(env), metav1.GetOptions{})
|
||||||
@ -162,7 +158,7 @@ func TestImpersonationProxy(t *testing.T) {
|
|||||||
|
|
||||||
// Create an impersonation proxy client with that CA data to use for the rest of this test.
|
// Create an impersonation proxy client with that CA data to use for the rest of this test.
|
||||||
// This client performs TLS checks, so it also provides test coverage that the impersonation proxy server is generating TLS certs correctly.
|
// This client performs TLS checks, so it also provides test coverage that the impersonation proxy server is generating TLS certs correctly.
|
||||||
var impersonationProxyClient *kubernetes.Clientset
|
var impersonationProxyClient kubernetes.Interface
|
||||||
if env.HasCapability(library.HasExternalLoadBalancerProvider) {
|
if env.HasCapability(library.HasExternalLoadBalancerProvider) {
|
||||||
impersonationProxyClient = impersonationProxyViaLoadBalancerClient(impersonationProxyURL, impersonationProxyCACertPEM, "")
|
impersonationProxyClient = impersonationProxyViaLoadBalancerClient(impersonationProxyURL, impersonationProxyCACertPEM, "")
|
||||||
} else {
|
} else {
|
||||||
@ -338,7 +334,7 @@ func TestImpersonationProxy(t *testing.T) {
|
|||||||
|
|
||||||
// Make a client which will send requests through the impersonation proxy and will also add
|
// Make a client which will send requests through the impersonation proxy and will also add
|
||||||
// impersonate headers to the request.
|
// impersonate headers to the request.
|
||||||
var doubleImpersonationClient *kubernetes.Clientset
|
var doubleImpersonationClient kubernetes.Interface
|
||||||
if env.HasCapability(library.HasExternalLoadBalancerProvider) {
|
if env.HasCapability(library.HasExternalLoadBalancerProvider) {
|
||||||
doubleImpersonationClient = impersonationProxyViaLoadBalancerClient(impersonationProxyURL, impersonationProxyCACertPEM, "other-user-to-impersonate")
|
doubleImpersonationClient = impersonationProxyViaLoadBalancerClient(impersonationProxyURL, impersonationProxyCACertPEM, "other-user-to-impersonate")
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user