From 3a8320a1d73444b3bb823300e94c3e2ee85fd6ef Mon Sep 17 00:00:00 2001 From: Cedric Brandily Date: Fri, 1 Apr 2016 23:42:27 +0200 Subject: Support client certificate/key This change enables to specify a client certificate/key with: * usual CLI options (--os-cert/--os-key) * usual environment variables ($OS_CERT/$OS_KEY) * os-client-config Change-Id: Ibeaaa5897ae37b37c1e91f3e47076e4e8e4a8ded Closes-Bug: #1565112 --- openstackclient/tests/test_shell.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'openstackclient/tests/test_shell.py') diff --git a/openstackclient/tests/test_shell.py b/openstackclient/tests/test_shell.py index ea3c6fe2..c134cb93 100644 --- a/openstackclient/tests/test_shell.py +++ b/openstackclient/tests/test_shell.py @@ -79,6 +79,8 @@ CLOUD_2 = { 'region_name': 'occ-cloud,krikkit,occ-env', 'log_file': '/tmp/test_log_file', 'log_level': 'debug', + 'cert': 'mycert', + 'key': 'mickey', } } } @@ -567,6 +569,24 @@ class TestShellCli(TestShell): self.assertEqual('foo', _shell.options.cacert) self.assertFalse(_shell.verify) + def test_shell_args_cert_options(self): + _shell = make_shell() + + # Default + fake_execute(_shell, "list user") + self.assertEqual('', _shell.options.cert) + self.assertEqual('', _shell.options.key) + + # --os-cert + fake_execute(_shell, "--os-cert mycert list user") + self.assertEqual('mycert', _shell.options.cert) + self.assertEqual('', _shell.options.key) + + # --os-key + fake_execute(_shell, "--os-key mickey list user") + self.assertEqual('', _shell.options.cert) + self.assertEqual('mickey', _shell.options.key) + def test_default_env(self): flag = "" kwargs = { @@ -670,6 +690,9 @@ class TestShellCli(TestShell): _shell.cloud.config['region_name'], ) + self.assertEqual('mycert', _shell.cloud.config['cert']) + self.assertEqual('mickey', _shell.cloud.config['key']) + @mock.patch("os_client_config.config.OpenStackConfig._load_vendor_file") @mock.patch("os_client_config.config.OpenStackConfig._load_config_file") def test_shell_args_precedence(self, config_mock, vendor_mock): -- cgit v1.2.1