|
16 | 16 | import datetime |
17 | 17 | import json |
18 | 18 | import os |
| 19 | +import io |
19 | 20 | import shutil |
20 | 21 | import tempfile |
21 | 22 | import unittest |
@@ -1257,6 +1258,14 @@ def test_load_kube_config(self): |
1257 | 1258 | client_configuration=actual) |
1258 | 1259 | self.assertEqual(expected, actual) |
1259 | 1260 |
|
| 1261 | + def test_load_kube_config_from_stringio(self): |
| 1262 | + expected = FakeConfig(host=TEST_HOST, |
| 1263 | + token=BEARER_TOKEN_FORMAT % TEST_DATA_BASE64) |
| 1264 | + kubeconfig = self._create_stringio_config() |
| 1265 | + actual = FakeConfig() |
| 1266 | + load_kube_config(config_file=kubeconfig, context="simple_token", client_configuration=actual) |
| 1267 | + self.assertEqual(expected, actual) |
| 1268 | + |
1260 | 1269 | def test_load_kube_config_from_dict(self): |
1261 | 1270 | expected = FakeConfig(host=TEST_HOST, |
1262 | 1271 | token=BEARER_TOKEN_FORMAT % TEST_DATA_BASE64) |
@@ -1633,6 +1642,11 @@ def _create_multi_config(self): |
1633 | 1642 | files.append(self._create_temp_file(yaml.safe_dump(part))) |
1634 | 1643 | return ENV_KUBECONFIG_PATH_SEPARATOR.join(files) |
1635 | 1644 |
|
| 1645 | + def _create_stringio_config(self): |
| 1646 | + obj = io.StringIO() |
| 1647 | + obj.write(self.TEST_KUBE_CONFIG_PART1) |
| 1648 | + return obj |
| 1649 | + |
1636 | 1650 | def test_list_kube_config_contexts(self): |
1637 | 1651 | kubeconfigs = self._create_multi_config() |
1638 | 1652 | expected_contexts = [ |
@@ -1660,6 +1674,7 @@ def test_new_client_from_config(self): |
1660 | 1674 | self.assertEqual(BEARER_TOKEN_FORMAT % TEST_DATA_BASE64, |
1661 | 1675 | client.configuration.api_key['authorization']) |
1662 | 1676 |
|
| 1677 | + |
1663 | 1678 | def test_save_changes(self): |
1664 | 1679 | kubeconfigs = self._create_multi_config() |
1665 | 1680 |
|
|
0 commit comments