@@ -102,7 +102,7 @@ def _raise_exception(st):
102102TEST_CLIENT_KEY_BASE64 = _base64 (TEST_CLIENT_KEY )
103103TEST_CLIENT_CERT = "client-cert"
104104TEST_CLIENT_CERT_BASE64 = _base64 (TEST_CLIENT_CERT )
105-
105+ TEST_TLS_SERVER_NAME = "kubernetes.io"
106106
107107TEST_OIDC_TOKEN = "test-oidc-token"
108108TEST_OIDC_INFO = "{\" name\" : \" test\" }"
@@ -592,7 +592,14 @@ class TestKubeConfigLoader(BaseTestCase):
592592 "cluster" : "clustertestcmdpath" ,
593593 "user" : "usertestcmdpathscope"
594594 }
595- }
595+ },
596+ {
597+ "name" : "tls-server-name" ,
598+ "context" : {
599+ "cluster" : "tls-server-name" ,
600+ "user" : "ssl"
601+ }
602+ },
596603 ],
597604 "clusters" : [
598605 {
@@ -634,7 +641,17 @@ class TestKubeConfigLoader(BaseTestCase):
634641 {
635642 "name" : "clustertestcmdpath" ,
636643 "cluster" : {}
637- }
644+ },
645+ {
646+ "name" : "tls-server-name" ,
647+ "cluster" : {
648+ "server" : TEST_SSL_HOST ,
649+ "certificate-authority-data" :
650+ TEST_CERTIFICATE_AUTH_BASE64 ,
651+ "insecure-skip-tls-verify" : False ,
652+ "tls-server-name" : TEST_TLS_SERVER_NAME ,
653+ }
654+ },
638655 ],
639656 "users" : [
640657 {
@@ -1251,6 +1268,22 @@ def test_ssl_no_verification(self):
12511268 active_context = "no_ssl_verification" ).load_and_set (actual )
12521269 self .assertEqual (expected , actual )
12531270
1271+ def test_tls_server_name (self ):
1272+ expected = FakeConfig (
1273+ host = TEST_SSL_HOST ,
1274+ token = BEARER_TOKEN_FORMAT % TEST_DATA_BASE64 ,
1275+ cert_file = self ._create_temp_file (TEST_CLIENT_CERT ),
1276+ key_file = self ._create_temp_file (TEST_CLIENT_KEY ),
1277+ ssl_ca_cert = self ._create_temp_file (TEST_CERTIFICATE_AUTH ),
1278+ verify_ssl = True ,
1279+ tls_server_name = TEST_TLS_SERVER_NAME
1280+ )
1281+ actual = FakeConfig ()
1282+ KubeConfigLoader (
1283+ config_dict = self .TEST_KUBE_CONFIG ,
1284+ active_context = "tls-server-name" ).load_and_set (actual )
1285+ self .assertEqual (expected , actual )
1286+
12541287 def test_list_contexts (self ):
12551288 loader = KubeConfigLoader (
12561289 config_dict = self .TEST_KUBE_CONFIG ,
0 commit comments