@@ -83,9 +83,9 @@ def _create_temp_file(self, content=""):
83
83
os .close (handler )
84
84
return name
85
85
86
- def expect_exception (self , func , message_part ):
86
+ def expect_exception (self , func , message_part , * args , ** kwargs ):
87
87
with self .assertRaises (ConfigException ) as context :
88
- func ()
88
+ func (* args , ** kwargs )
89
89
self .assertIn (message_part , str (context .exception ))
90
90
91
91
@@ -473,8 +473,7 @@ def test_no_user_context(self):
473
473
actual = FakeConfig ()
474
474
KubeConfigLoader (
475
475
config_dict = self .TEST_KUBE_CONFIG ,
476
- active_context = "no_user" ,
477
- client_configuration = actual ).load_and_set ()
476
+ active_context = "no_user" ).load_and_set (actual )
478
477
self .assertEqual (expected , actual )
479
478
480
479
def test_simple_token (self ):
@@ -483,8 +482,7 @@ def test_simple_token(self):
483
482
actual = FakeConfig ()
484
483
KubeConfigLoader (
485
484
config_dict = self .TEST_KUBE_CONFIG ,
486
- active_context = "simple_token" ,
487
- client_configuration = actual ).load_and_set ()
485
+ active_context = "simple_token" ).load_and_set (actual )
488
486
self .assertEqual (expected , actual )
489
487
490
488
def test_load_user_token (self ):
@@ -502,9 +500,8 @@ def test_gcp_no_refresh(self):
502
500
KubeConfigLoader (
503
501
config_dict = self .TEST_KUBE_CONFIG ,
504
502
active_context = "gcp" ,
505
- client_configuration = actual ,
506
503
get_google_credentials = lambda : _raise_exception (
507
- "SHOULD NOT BE CALLED" )).load_and_set ()
504
+ "SHOULD NOT BE CALLED" )).load_and_set (actual )
508
505
self .assertEqual (expected , actual )
509
506
510
507
def test_load_gcp_token_no_refresh (self ):
@@ -536,8 +533,7 @@ def test_user_pass(self):
536
533
actual = FakeConfig ()
537
534
KubeConfigLoader (
538
535
config_dict = self .TEST_KUBE_CONFIG ,
539
- active_context = "user_pass" ,
540
- client_configuration = actual ).load_and_set ()
536
+ active_context = "user_pass" ).load_and_set (actual )
541
537
self .assertEqual (expected , actual )
542
538
543
539
def test_load_user_pass_token (self ):
@@ -548,12 +544,13 @@ def test_load_user_pass_token(self):
548
544
self .assertEqual (TEST_BASIC_TOKEN , loader .token )
549
545
550
546
def test_ssl_no_cert_files (self ):
551
- actual = FakeConfig ()
552
547
loader = KubeConfigLoader (
553
548
config_dict = self .TEST_KUBE_CONFIG ,
554
- active_context = "ssl-no_file" ,
555
- client_configuration = actual )
556
- self .expect_exception (loader .load_and_set , "does not exists" )
549
+ active_context = "ssl-no_file" )
550
+ self .expect_exception (
551
+ loader .load_and_set ,
552
+ "does not exists" ,
553
+ FakeConfig ())
557
554
558
555
def test_ssl (self ):
559
556
expected = FakeConfig (
@@ -566,8 +563,7 @@ def test_ssl(self):
566
563
actual = FakeConfig ()
567
564
KubeConfigLoader (
568
565
config_dict = self .TEST_KUBE_CONFIG ,
569
- active_context = "ssl" ,
570
- client_configuration = actual ).load_and_set ()
566
+ active_context = "ssl" ).load_and_set (actual )
571
567
self .assertEqual (expected , actual )
572
568
573
569
def test_ssl_no_verification (self ):
@@ -582,8 +578,7 @@ def test_ssl_no_verification(self):
582
578
actual = FakeConfig ()
583
579
KubeConfigLoader (
584
580
config_dict = self .TEST_KUBE_CONFIG ,
585
- active_context = "no_ssl_verification" ,
586
- client_configuration = actual ).load_and_set ()
581
+ active_context = "no_ssl_verification" ).load_and_set (actual )
587
582
self .assertEqual (expected , actual )
588
583
589
584
def test_list_contexts (self ):
@@ -631,8 +626,7 @@ def test_ssl_with_relative_ssl_files(self):
631
626
KubeConfigLoader (
632
627
config_dict = self .TEST_KUBE_CONFIG ,
633
628
active_context = "ssl-local-file" ,
634
- config_base_path = temp_dir ,
635
- client_configuration = actual ).load_and_set ()
629
+ config_base_path = temp_dir ).load_and_set (actual )
636
630
self .assertEqual (expected , actual )
637
631
finally :
638
632
shutil .rmtree (temp_dir )
@@ -663,9 +657,9 @@ def test_new_client_from_config(self):
663
657
config_file = self ._create_temp_file (yaml .dump (self .TEST_KUBE_CONFIG ))
664
658
client = new_client_from_config (
665
659
config_file = config_file , context = "simple_token" )
666
- self .assertEqual (TEST_HOST , client .config .host )
660
+ self .assertEqual (TEST_HOST , client .configuration .host )
667
661
self .assertEqual (BEARER_TOKEN_FORMAT % TEST_DATA_BASE64 ,
668
- client .config .api_key ['authorization' ])
662
+ client .configuration .api_key ['authorization' ])
669
663
670
664
def test_no_users_section (self ):
671
665
expected = FakeConfig (host = TEST_HOST )
@@ -674,17 +668,15 @@ def test_no_users_section(self):
674
668
del test_kube_config ['users' ]
675
669
KubeConfigLoader (
676
670
config_dict = test_kube_config ,
677
- active_context = "gcp" ,
678
- client_configuration = actual ).load_and_set ()
671
+ active_context = "gcp" ).load_and_set (actual )
679
672
self .assertEqual (expected , actual )
680
673
681
674
def test_non_existing_user (self ):
682
675
expected = FakeConfig (host = TEST_HOST )
683
676
actual = FakeConfig ()
684
677
KubeConfigLoader (
685
678
config_dict = self .TEST_KUBE_CONFIG ,
686
- active_context = "non_existing_user" ,
687
- client_configuration = actual ).load_and_set ()
679
+ active_context = "non_existing_user" ).load_and_set (actual )
688
680
self .assertEqual (expected , actual )
689
681
690
682
0 commit comments