@@ -373,6 +373,13 @@ class TestKubeConfigLoader(BaseTestCase):
373
373
"user" : "expired_oidc"
374
374
}
375
375
},
376
+ {
377
+ "name" : "expired_oidc_nocert" ,
378
+ "context" : {
379
+ "cluster" : "default" ,
380
+ "user" : "expired_oidc_nocert"
381
+ }
382
+ },
376
383
{
377
384
"name" : "user_pass" ,
378
385
"context" : {
@@ -519,6 +526,22 @@ class TestKubeConfigLoader(BaseTestCase):
519
526
}
520
527
}
521
528
},
529
+ {
530
+ "name" : "expired_oidc_nocert" ,
531
+ "user" : {
532
+ "auth-provider" : {
533
+ "name" : "oidc" ,
534
+ "config" : {
535
+ "client-id" : "tectonic-kubectl" ,
536
+ "client-secret" : "FAKE_SECRET" ,
537
+ "id-token" : TEST_OIDC_EXPIRED_LOGIN ,
538
+ "idp-issuer-url" : "https://example.org/identity" ,
539
+ "refresh-token" :
540
+ "lucWJjEhlxZW01cXI3YmVlcYnpxNGhzk"
541
+ }
542
+ }
543
+ }
544
+ },
522
545
{
523
546
"name" : "user_pass" ,
524
547
"user" : {
@@ -649,6 +672,31 @@ def test_oidc_with_refresh(self, mock_ApiClient, mock_OAuth2Session):
649
672
self .assertTrue (loader ._load_oid_token ())
650
673
self .assertEqual ("Bearer abc123" , loader .token )
651
674
675
+ @mock .patch ('kubernetes.config.kube_config.OAuth2Session.refresh_token' )
676
+ @mock .patch ('kubernetes.config.kube_config.ApiClient.request' )
677
+ def test_oidc_with_refresh_nocert (self , mock_ApiClient , mock_OAuth2Session ):
678
+ mock_response = mock .MagicMock ()
679
+ type(mock_response ).status = mock .PropertyMock (
680
+ return_value = 200
681
+ )
682
+ type(mock_response ).data = mock .PropertyMock (
683
+ return_value = json .dumps ({
684
+ "token_endpoint" : "https://example.org/identity/token"
685
+ })
686
+ )
687
+
688
+ mock_ApiClient .return_value = mock_response
689
+
690
+ mock_OAuth2Session .return_value = {"id_token" : "abc123" ,
691
+ "refresh_token" : "newtoken123" }
692
+
693
+ loader = KubeConfigLoader (
694
+ config_dict = self .TEST_KUBE_CONFIG ,
695
+ active_context = "expired_oidc_nocert" ,
696
+ )
697
+ self .assertTrue (loader ._load_oid_token ())
698
+ self .assertEqual ("Bearer abc123" , loader .token )
699
+
652
700
def test_user_pass (self ):
653
701
expected = FakeConfig (host = TEST_HOST , token = TEST_BASIC_TOKEN )
654
702
actual = FakeConfig ()
0 commit comments