@@ -102,6 +102,7 @@ def _raise_exception(st):
102102TEST_CLIENT_CERT = "client-cert"
103103TEST_CLIENT_CERT_BASE64 = _base64 (TEST_CLIENT_CERT )
104104TEST_TLS_SERVER_NAME = "kubernetes.io"
105+ TEST_PROXY_URL = "http://proxy.example.com:3128"
105106
106107TEST_OIDC_TOKEN = "test-oidc-token"
107108TEST_OIDC_INFO = "{\" name\" : \" test\" }"
@@ -580,6 +581,13 @@ class TestKubeConfigLoader(BaseTestCase):
580581 "user" : "ssl"
581582 }
582583 },
584+ {
585+ "name" : "proxy_cluster_context" ,
586+ "context" : {
587+ "cluster" : "proxy_cluster" ,
588+ "user" : "simple_token"
589+ }
590+ },
583591 ],
584592 "clusters" : [
585593 {
@@ -632,6 +640,13 @@ class TestKubeConfigLoader(BaseTestCase):
632640 "tls-server-name" : TEST_TLS_SERVER_NAME ,
633641 }
634642 },
643+ {
644+ "name" : "proxy_cluster" ,
645+ "cluster" : {
646+ "server" : TEST_HOST ,
647+ "proxy-url" : TEST_PROXY_URL ,
648+ }
649+ },
635650 ],
636651 "users" : [
637652 {
@@ -1136,6 +1151,18 @@ def test_tls_server_name(self):
11361151 active_context = "tls-server-name" ).load_and_set (actual )
11371152 self .assertEqual (expected , actual )
11381153
1154+ def test_proxy_url_from_cluster (self ):
1155+ expected = FakeConfig (
1156+ host = TEST_HOST ,
1157+ token = BEARER_TOKEN_FORMAT % TEST_DATA_BASE64 ,
1158+ proxy = TEST_PROXY_URL ,
1159+ )
1160+ actual = FakeConfig ()
1161+ KubeConfigLoader (
1162+ config_dict = self .TEST_KUBE_CONFIG ,
1163+ active_context = "proxy_cluster_context" ).load_and_set (actual )
1164+ self .assertEqual (expected , actual )
1165+
11391166 def test_list_contexts (self ):
11401167 loader = KubeConfigLoader (
11411168 config_dict = self .TEST_KUBE_CONFIG ,
@@ -1285,6 +1312,14 @@ def test_new_client_from_config(self):
12851312 self .assertEqual (BEARER_TOKEN_FORMAT % TEST_DATA_BASE64 ,
12861313 client .configuration .api_key ['BearerToken' ])
12871314
1315+ def test_new_client_from_config_proxy (self ):
1316+ config_file = self ._create_temp_file (
1317+ yaml .safe_dump (self .TEST_KUBE_CONFIG ))
1318+ client = new_client_from_config (
1319+ config_file = config_file , context = "proxy_cluster_context" )
1320+ self .assertEqual (TEST_HOST , client .configuration .host )
1321+ self .assertEqual (TEST_PROXY_URL , client .configuration .proxy )
1322+
12881323 def test_new_client_from_config_dict (self ):
12891324 client = new_client_from_config_dict (
12901325 config_dict = self .TEST_KUBE_CONFIG , context = "simple_token" )
0 commit comments