@@ -235,13 +235,17 @@ def __eq__(self, other):
235
235
if k not in other .__dict__ :
236
236
return
237
237
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 :
241
247
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 :
245
249
if other .__dict__ [k ] != v :
246
250
return
247
251
else :
@@ -301,6 +305,13 @@ class TestKubeConfigLoader(BaseTestCase):
301
305
"user" : "ssl"
302
306
}
303
307
},
308
+ {
309
+ "name" : "no_ssl_verification" ,
310
+ "context" : {
311
+ "cluster" : "no_ssl_verification" ,
312
+ "user" : "ssl"
313
+ }
314
+ },
304
315
{
305
316
"name" : "ssl-no_file" ,
306
317
"context" : {
@@ -344,6 +355,13 @@ class TestKubeConfigLoader(BaseTestCase):
344
355
"certificate-authority-data" : TEST_CERTIFICATE_AUTH_BASE64 ,
345
356
}
346
357
},
358
+ {
359
+ "name" : "no_ssl_verification" ,
360
+ "cluster" : {
361
+ "server" : TEST_SSL_HOST ,
362
+ "insecure-skip-tls-verify" : "true" ,
363
+ }
364
+ },
347
365
],
348
366
"users" : [
349
367
{
@@ -487,6 +505,22 @@ def test_ssl(self):
487
505
client_configuration = actual ).load_and_set ()
488
506
self .assertEqual (expected , actual )
489
507
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
+
490
524
def test_list_contexts (self ):
491
525
loader = KubeConfigLoader (
492
526
config_dict = self .TEST_KUBE_CONFIG ,
0 commit comments