mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
test/integration/client: ditch unused code
Signed-off-by: Andrew Keesler <akeesler@vmware.com>
This commit is contained in:
parent
b0abe89ae2
commit
c984a1c834
@ -24,7 +24,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
@ -35,7 +34,6 @@ import (
|
|||||||
clientset "k8s.io/client-go/kubernetes"
|
clientset "k8s.io/client-go/kubernetes"
|
||||||
"k8s.io/client-go/rest"
|
"k8s.io/client-go/rest"
|
||||||
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
|
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
|
||||||
"k8s.io/client-go/transport"
|
|
||||||
"k8s.io/client-go/util/cert"
|
"k8s.io/client-go/util/cert"
|
||||||
|
|
||||||
kubeapiservertesting "k8s.io/kubernetes/cmd/kube-apiserver/app/testing"
|
kubeapiservertesting "k8s.io/kubernetes/cmd/kube-apiserver/app/testing"
|
||||||
@ -271,7 +269,7 @@ func TestExecPlugin(t *testing.T) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
wantAuthorizationHeaderValues: [][]string{{"Bearer " + clientUnauthorizedToken}},
|
wantAuthorizationHeaderValues: [][]string{{"Bearer " + clientUnauthorizedToken}},
|
||||||
wantCertificate: x509KeyPair([]byte(unauthorizedCert), []byte(unauthorizedKey), true),
|
wantCertificate: x509KeyPair(unauthorizedCert, unauthorizedKey, true),
|
||||||
wantClientErrorPrefix: "Unauthorized",
|
wantClientErrorPrefix: "Unauthorized",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -337,17 +335,11 @@ func TestExecPlugin(t *testing.T) {
|
|||||||
c.KeyData = unauthorizedKey
|
c.KeyData = unauthorizedKey
|
||||||
},
|
},
|
||||||
wantAuthorizationHeaderValues: [][]string{{"Bearer " + clientAuthorizedToken}},
|
wantAuthorizationHeaderValues: [][]string{{"Bearer " + clientAuthorizedToken}},
|
||||||
wantCertificate: x509KeyPair([]byte(unauthorizedCert), []byte(unauthorizedKey), false),
|
wantCertificate: x509KeyPair(unauthorizedCert, unauthorizedKey, false),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
tmpDir, err := ioutil.TempDir("", "kubernetes-client-exec-test-plugin-dir-*")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(tmpDir)
|
|
||||||
|
|
||||||
var authorizationHeaderValues syncedHeaderValues
|
var authorizationHeaderValues syncedHeaderValues
|
||||||
clientConfig := rest.AnonymousClientConfig(result.ClientConfig)
|
clientConfig := rest.AnonymousClientConfig(result.ClientConfig)
|
||||||
clientConfig.ExecProvider = &clientcmdapi.ExecConfig{
|
clientConfig.ExecProvider = &clientcmdapi.ExecConfig{
|
||||||
@ -355,12 +347,12 @@ func TestExecPlugin(t *testing.T) {
|
|||||||
// TODO(ankeesler): move to v1 once exec plugins go GA.
|
// TODO(ankeesler): move to v1 once exec plugins go GA.
|
||||||
APIVersion: "client.authentication.k8s.io/v1beta1",
|
APIVersion: "client.authentication.k8s.io/v1beta1",
|
||||||
}
|
}
|
||||||
clientConfig.Wrap(transport.WrapperFunc(func(rt http.RoundTripper) http.RoundTripper {
|
clientConfig.Wrap(func(rt http.RoundTripper) http.RoundTripper {
|
||||||
return roundTripperFunc(func(req *http.Request) (*http.Response, error) {
|
return roundTripperFunc(func(req *http.Request) (*http.Response, error) {
|
||||||
authorizationHeaderValues.append(req.Header.Values("Authorization"))
|
authorizationHeaderValues.append(req.Header.Values("Authorization"))
|
||||||
return rt.RoundTrip(req)
|
return rt.RoundTrip(req)
|
||||||
})
|
})
|
||||||
}))
|
})
|
||||||
|
|
||||||
if test.clientConfigFunc != nil {
|
if test.clientConfigFunc != nil {
|
||||||
test.clientConfigFunc(clientConfig)
|
test.clientConfigFunc(clientConfig)
|
||||||
|
Loading…
Reference in New Issue
Block a user