@@ -235,13 +235,17 @@ def __eq__(self, other):
235235 if k not in other .__dict__ :
236236 return
237237 if k in self .FILE_KEYS :
238- try :
239- with open (v ) as f1 , open (other .__dict__ [k ]) as f2 :
240- if f1 .read () != f2 .read ():
238+ if v and other .__dict__ [k ]:
239+ try :
240+ with open (v ) as f1 , open (other .__dict__ [k ]) as f2 :
241+ if f1 .read () != f2 .read ():
242+ return
243+ except IOError :
244+ # fall back to only compare filenames in case we are
245+ # testing the passing of filenames to the config
246+ if other .__dict__ [k ] != v :
241247 return
242- except IOError :
243- # fall back to only compare filenames in case we are
244- # testing the passing of filenames to the config
248+ else :
245249 if other .__dict__ [k ] != v :
246250 return
247251 else :
@@ -301,6 +305,13 @@ class TestKubeConfigLoader(BaseTestCase):
301305 "user" : "ssl"
302306 }
303307 },
308+ {
309+ "name" : "no_ssl_verification" ,
310+ "context" : {
311+ "cluster" : "no_ssl_verification" ,
312+ "user" : "ssl"
313+ }
314+ },
304315 {
305316 "name" : "ssl-no_file" ,
306317 "context" : {
@@ -344,6 +355,13 @@ class TestKubeConfigLoader(BaseTestCase):
344355 "certificate-authority-data" : TEST_CERTIFICATE_AUTH_BASE64 ,
345356 }
346357 },
358+ {
359+ "name" : "no_ssl_verification" ,
360+ "cluster" : {
361+ "server" : TEST_SSL_HOST ,
362+ "insecure-skip-tls-verify" : "true" ,
363+ }
364+ },
347365 ],
348366 "users" : [
349367 {
@@ -487,6 +505,22 @@ def test_ssl(self):
487505 client_configuration = actual ).load_and_set ()
488506 self .assertEqual (expected , actual )
489507
508+ def test_ssl_no_verification (self ):
509+ expected = FakeConfig (
510+ host = TEST_SSL_HOST ,
511+ token = BEARER_TOKEN_FORMAT % TEST_DATA_BASE64 ,
512+ cert_file = self ._create_temp_file (TEST_CLIENT_CERT ),
513+ key_file = self ._create_temp_file (TEST_CLIENT_KEY ),
514+ verify_ssl = False ,
515+ ssl_ca_cert = None ,
516+ )
517+ actual = FakeConfig ()
518+ KubeConfigLoader (
519+ config_dict = self .TEST_KUBE_CONFIG ,
520+ active_context = "no_ssl_verification" ,
521+ client_configuration = actual ).load_and_set ()
522+ self .assertEqual (expected , actual )
523+
490524 def test_list_contexts (self ):
491525 loader = KubeConfigLoader (
492526 config_dict = self .TEST_KUBE_CONFIG ,
0 commit comments