@@ -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,32 @@ 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 (
678
+ self , mock_ApiClient , mock_OAuth2Session ):
679
+ mock_response = mock .MagicMock ()
680
+ type(mock_response ).status = mock .PropertyMock (
681
+ return_value = 200
682
+ )
683
+ type(mock_response ).data = mock .PropertyMock (
684
+ return_value = json .dumps ({
685
+ "token_endpoint" : "https://example.org/identity/token"
686
+ })
687
+ )
688
+
689
+ mock_ApiClient .return_value = mock_response
690
+
691
+ mock_OAuth2Session .return_value = {"id_token" : "abc123" ,
692
+ "refresh_token" : "newtoken123" }
693
+
694
+ loader = KubeConfigLoader (
695
+ config_dict = self .TEST_KUBE_CONFIG ,
696
+ active_context = "expired_oidc_nocert" ,
697
+ )
698
+ self .assertTrue (loader ._load_oid_token ())
699
+ self .assertEqual ("Bearer abc123" , loader .token )
700
+
652
701
def test_user_pass (self ):
653
702
expected = FakeConfig (host = TEST_HOST , token = TEST_BASIC_TOKEN )
654
703
actual = FakeConfig ()
0 commit comments