mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	make client authentication optional for test kube-apiserver
This commit is contained in:
		@@ -47,6 +47,9 @@ type TearDownFunc func()
 | 
			
		||||
type TestServerInstanceOptions struct {
 | 
			
		||||
	// DisableStorageCleanup Disable the automatic storage cleanup
 | 
			
		||||
	DisableStorageCleanup bool
 | 
			
		||||
 | 
			
		||||
	// Enable cert-auth for the kube-apiserver
 | 
			
		||||
	EnableCertAuth bool
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// TestServer return values supplied by kube-test-ApiServer
 | 
			
		||||
@@ -68,6 +71,7 @@ type Logger interface {
 | 
			
		||||
func NewDefaultTestServerOptions() *TestServerInstanceOptions {
 | 
			
		||||
	return &TestServerInstanceOptions{
 | 
			
		||||
		DisableStorageCleanup: false,
 | 
			
		||||
		EnableCertAuth:        true,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -124,7 +128,8 @@ func StartTestServer(t Logger, instanceOptions *TestServerInstanceOptions, custo
 | 
			
		||||
	}
 | 
			
		||||
	s.SecureServing.ServerCert.CertDirectory = result.TmpDir
 | 
			
		||||
 | 
			
		||||
	// create optional certificates for aggregation and client-cert auth
 | 
			
		||||
	if instanceOptions.EnableCertAuth {
 | 
			
		||||
		// create certificates for aggregation and client-cert auth
 | 
			
		||||
		proxySigningKey, err := testutil.NewPrivateKey()
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return result, err
 | 
			
		||||
@@ -151,6 +156,8 @@ func StartTestServer(t Logger, instanceOptions *TestServerInstanceOptions, custo
 | 
			
		||||
			return result, err
 | 
			
		||||
		}
 | 
			
		||||
		s.Authentication.ClientCert.ClientCA = clientCACertFile
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	s.SecureServing.ExternalAddress = s.SecureServing.Listener.Addr().(*net.TCPAddr).IP // use listener addr although it is a loopback device
 | 
			
		||||
 | 
			
		||||
	_, thisFile, _, ok := runtime.Caller(0)
 | 
			
		||||
 
 | 
			
		||||
@@ -58,7 +58,7 @@ func TestAggregatedAPIServer(t *testing.T) {
 | 
			
		||||
	stopCh := make(chan struct{})
 | 
			
		||||
	defer close(stopCh)
 | 
			
		||||
 | 
			
		||||
	testServer := kastesting.StartTestServerOrDie(t, nil, nil, framework.SharedEtcd())
 | 
			
		||||
	testServer := kastesting.StartTestServerOrDie(t, &kastesting.TestServerInstanceOptions{EnableCertAuth: true}, nil, framework.SharedEtcd())
 | 
			
		||||
	defer testServer.TearDownFn()
 | 
			
		||||
	kubeClientConfig := rest.CopyConfig(testServer.ClientConfig)
 | 
			
		||||
	// force json because everything speaks it
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user