@@ -102,7 +102,7 @@ def _raise_exception(st):
102
102
TEST_CLIENT_KEY_BASE64 = _base64 (TEST_CLIENT_KEY )
103
103
TEST_CLIENT_CERT = "client-cert"
104
104
TEST_CLIENT_CERT_BASE64 = _base64 (TEST_CLIENT_CERT )
105
-
105
+ TEST_TLS_SERVER_NAME = "kubernetes.io"
106
106
107
107
TEST_OIDC_TOKEN = "test-oidc-token"
108
108
TEST_OIDC_INFO = "{\" name\" : \" test\" }"
@@ -592,7 +592,14 @@ class TestKubeConfigLoader(BaseTestCase):
592
592
"cluster" : "clustertestcmdpath" ,
593
593
"user" : "usertestcmdpathscope"
594
594
}
595
- }
595
+ },
596
+ {
597
+ "name" : "tls-server-name" ,
598
+ "context" : {
599
+ "cluster" : "tls-server-name" ,
600
+ "user" : "ssl"
601
+ }
602
+ },
596
603
],
597
604
"clusters" : [
598
605
{
@@ -634,7 +641,17 @@ class TestKubeConfigLoader(BaseTestCase):
634
641
{
635
642
"name" : "clustertestcmdpath" ,
636
643
"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
+ },
638
655
],
639
656
"users" : [
640
657
{
@@ -1251,6 +1268,22 @@ def test_ssl_no_verification(self):
1251
1268
active_context = "no_ssl_verification" ).load_and_set (actual )
1252
1269
self .assertEqual (expected , actual )
1253
1270
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
+
1254
1287
def test_list_contexts (self ):
1255
1288
loader = KubeConfigLoader (
1256
1289
config_dict = self .TEST_KUBE_CONFIG ,
0 commit comments