Skip to content
This repository was archived by the owner on Mar 13, 2022. It is now read-only.

Commit faf2e0c

Browse files
committed
Fix apiserver_id 'get' method
1 parent a25f49e commit faf2e0c

File tree

2 files changed

+6
-66
lines changed

2 files changed

+6
-66
lines changed

config/kube_config.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,12 @@ def _refresh_azure_token(self, config):
326326
)
327327
refresh_token = config['refresh-token']
328328
client_id = config['client-id']
329-
apiserver_id = config.get(
330-
'apiserver-id',
331-
'00000002-0000-0000-c000-000000000000')
329+
apiserver_id = '00000002-0000-0000-c000-000000000000'
330+
try:
331+
apiserver_id = config['apiserver-id']
332+
except ConfigException:
333+
# We've already set a default above
334+
pass
332335
token_response = context.acquire_token_with_refresh_token(
333336
refresh_token, client_id, apiserver_id)
334337

config/kube_config_test.py

-63
Original file line numberDiff line numberDiff line change
@@ -460,20 +460,6 @@ class TestKubeConfigLoader(BaseTestCase):
460460
"user": "azure_str_error"
461461
}
462462
},
463-
{
464-
"name": "azure_no_apiserver",
465-
"context": {
466-
"cluster": "default",
467-
"user": "azure_no_apiserver"
468-
}
469-
},
470-
{
471-
"name": "azure_bad_apiserver",
472-
"context": {
473-
"cluster": "default",
474-
"user": "azure_bad_apiserver"
475-
}
476-
},
477463
{
478464
"name": "expired_oidc",
479465
"context": {
@@ -771,39 +757,6 @@ class TestKubeConfigLoader(BaseTestCase):
771757
}
772758
}
773759
},
774-
{
775-
"name": "azure_no_apiserver",
776-
"user": {
777-
"auth-provider": {
778-
"config": {
779-
"access-token": TEST_AZURE_TOKEN,
780-
"environment": "AzurePublicCloud",
781-
"expires-in": "0",
782-
"expires-on": "156207275",
783-
"refresh-token": "refreshToken",
784-
"tenant-id": "9d2ac018-e843-4e14-9e2b-4e0ddac75433"
785-
},
786-
"name": "azure"
787-
}
788-
}
789-
},
790-
{
791-
"name": "azure_bad_apiserver",
792-
"user": {
793-
"auth-provider": {
794-
"config": {
795-
"access-token": TEST_AZURE_TOKEN,
796-
"apiserver-id": "ApiserverId",
797-
"environment": "AzurePublicCloud",
798-
"expires-in": "0",
799-
"expires-on": "156207275",
800-
"refresh-token": "refreshToken",
801-
"tenant-id": "9d2ac018-e843-4e14-9e2b-4e0ddac75433"
802-
},
803-
"name": "azure"
804-
}
805-
}
806-
},
807760
{
808761
"name": "expired_oidc",
809762
"user": {
@@ -1161,22 +1114,6 @@ def test_azure_with_expired_int_error(self):
11611114
provider = loader._user['auth-provider']
11621115
self.assertRaises(ValueError, loader._azure_is_expired, provider)
11631116

1164-
def test_azure_with_no_apiserver(self):
1165-
loader = KubeConfigLoader(
1166-
config_dict=self.TEST_KUBE_CONFIG,
1167-
active_context="azure_no_apiserver",
1168-
)
1169-
provider = loader._user['auth-provider']
1170-
self.assertTrue(loader._azure_is_expired(provider))
1171-
1172-
def test_azure_with_bad_apiserver(self):
1173-
loader = KubeConfigLoader(
1174-
config_dict=self.TEST_KUBE_CONFIG,
1175-
active_context="azure_bad_apiserver",
1176-
)
1177-
provider = loader._user['auth-provider']
1178-
self.assertTrue(loader._azure_is_expired(provider))
1179-
11801117
def test_user_pass(self):
11811118
expected = FakeConfig(host=TEST_HOST, token=TEST_BASIC_TOKEN)
11821119
actual = FakeConfig()

0 commit comments

Comments
 (0)