Skip to content

Commit

Permalink
fix: config reader handles bool types (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomplus committed Aug 22, 2022
1 parent 7bbb327 commit ae5fd81
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion kubernetes_asyncio/config/kube_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ def safe_get(self, key):

def __getitem__(self, key):
v = self.safe_get(key)
if not v:
if v is None:
raise ConfigException(
'Invalid kube-config file. Expected key %s in %s'
% (key, self.name))
Expand Down
31 changes: 30 additions & 1 deletion kubernetes_asyncio/config/kube_config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,13 @@ class TestKubeConfigLoader(BaseTestCase):
"user": "ssl"
}
},
{
"name": "ssl_verification",
"context": {
"cluster": "ssl_verification",
"user": "ssl"
}
},
{
"name": "ssl-no_file",
"context": {
Expand Down Expand Up @@ -461,7 +468,14 @@ class TestKubeConfigLoader(BaseTestCase):
"name": "no_ssl_verification",
"cluster": {
"server": TEST_SSL_HOST,
"insecure-skip-tls-verify": "true",
"insecure-skip-tls-verify": True,
}
},
{
"name": "ssl_verification",
"cluster": {
"server": TEST_SSL_HOST,
"insecure-skip-tls-verify": False,
}
},
],
Expand Down Expand Up @@ -795,6 +809,21 @@ async def test_ssl_no_verification(self):
active_context="no_ssl_verification").load_and_set(actual)
self.assertEqual(expected, actual)

async def test_ssl_verification(self):
expected = FakeConfig(
host=TEST_SSL_HOST,
token=BEARER_TOKEN_FORMAT % TEST_DATA_BASE64,
cert_file=self._create_temp_file(TEST_CLIENT_CERT),
key_file=self._create_temp_file(TEST_CLIENT_KEY),
verify_ssl=True,
ssl_ca_cert=None,
)
actual = FakeConfig()
await KubeConfigLoader(
config_dict=self.TEST_KUBE_CONFIG,
active_context="ssl_verification").load_and_set(actual)
self.assertEqual(expected, actual)

def test_list_contexts(self):
loader = KubeConfigLoader(
config_dict=self.TEST_KUBE_CONFIG,
Expand Down

0 comments on commit ae5fd81

Please sign in to comment.