1717
1818from kubernetes .client import api_client
1919from kubernetes .client .apis import core_v1_api
20+ from kubernetes .client .configuration import configuration
2021from kubernetes .e2e_test import base
2122
2223
2324class TestClient (unittest .TestCase ):
25+
26+ @classmethod
27+ def setUpClass (cls ):
28+ cls .API_URL = 'http://127.0.0.1:8080/'
29+ cls .config = configuration
30+
2431 @unittest .skipUnless (
2532 base .is_k8s_running (), "Kubernetes is not available" )
2633 def test_pod_apis (self ):
27- client = api_client .ApiClient ('http://127.0.0.1:8080/' )
34+ client = api_client .ApiClient (self . API_URL , config = self . config )
2835 api = core_v1_api .CoreV1Api (client )
2936
3037 name = 'test-' + str (uuid .uuid4 ())
@@ -53,7 +60,7 @@ def test_pod_apis(self):
5360 @unittest .skipUnless (
5461 base .is_k8s_running (), "Kubernetes is not available" )
5562 def test_service_apis (self ):
56- client = api_client .ApiClient ('http://127.0.0.1:8080/' )
63+ client = api_client .ApiClient (self . API_URL , config = self . config )
5764 api = core_v1_api .CoreV1Api (client )
5865
5966 name = 'frontend-' + str (uuid .uuid4 ())
@@ -94,7 +101,7 @@ def test_service_apis(self):
94101 @unittest .skipUnless (
95102 base .is_k8s_running (), "Kubernetes is not available" )
96103 def test_replication_controller_apis (self ):
97- client = api_client .ApiClient ('http://127.0.0.1:8080/' )
104+ client = api_client .ApiClient (self . API_URL , config = self . config )
98105 api = core_v1_api .CoreV1Api (client )
99106
100107 name = 'frontend-' + str (uuid .uuid4 ())
@@ -129,7 +136,7 @@ def test_replication_controller_apis(self):
129136 @unittest .skipUnless (
130137 base .is_k8s_running (), "Kubernetes is not available" )
131138 def test_configmap_apis (self ):
132- client = api_client .ApiClient ('http://127.0.0.1:8080/' )
139+ client = api_client .ApiClient (self . API_URL , config = self . config )
133140 api = core_v1_api .CoreV1Api (client )
134141
135142 name = 'test-configmap-' + str (uuid .uuid4 ())
@@ -167,10 +174,18 @@ def test_configmap_apis(self):
167174 @unittest .skipUnless (
168175 base .is_k8s_running (), "Kubernetes is not available" )
169176 def test_node_apis (self ):
170- client = api_client .ApiClient ('http://127.0.0.1:8080/' )
177+ client = api_client .ApiClient (self . API_URL , config = self . config )
171178 api = core_v1_api .CoreV1Api (client )
172179
173180 for item in api .list_node ().items :
174181 node = api .read_node (name = item .metadata .name )
175182 self .assertTrue (len (node .metadata .labels ) > 0 )
176- self .assertTrue (isinstance (node .metadata .labels , dict ))
183+ self .assertTrue (isinstance (node .metadata .labels , dict ))
184+
185+
186+ class TestClientSSL (TestClient ):
187+
188+ @classmethod
189+ def setUpClass (cls ):
190+ cls .API_URL = 'https://127.0.0.1:8443/'
191+ cls .config = base .setSSLConfiguration ()
0 commit comments