summaryrefslogtreecommitdiff
path: root/cinderclient/tests/unit/test_shell.py
diff options
context:
space:
mode:
authorCedric Brandily <zzelle@gmail.com>2016-04-01 00:48:06 +0200
committerCedric Brandily <zzelle@gmail.com>2016-05-17 15:02:00 +0200
commit80d3edc71e2c746c692f2a8f9aecd3dee4429dab (patch)
tree5bc5584bccbaa8b6e9e8ec14ef609e44e5df1100 /cinderclient/tests/unit/test_shell.py
parentd2daa7ba947adbd9d0fe3e1f89d05940a28fc546 (diff)
downloadpython-cinderclient-80d3edc71e2c746c692f2a8f9aecd3dee4429dab.tar.gz
Support --os-key option
Currently we can specify a client certificate key using --os-key option inherited from keystoneclient cli options but it has no effect because keystoneclient Session expects as cert argument, one of the followings: * None (no client certificate), * a path to client certificate, * a tuple with client certificate/key paths. The change updates cinderclient code to support the last case (ie: os_cert and os_key are non-empty) in order to take into --os-key option and OS_KEY environment variable. Closes-Bug: #1564646 Change-Id: I258fd554ad2d6a5413ffe778acefa3a0b83e591f
Diffstat (limited to 'cinderclient/tests/unit/test_shell.py')
-rw-r--r--cinderclient/tests/unit/test_shell.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/cinderclient/tests/unit/test_shell.py b/cinderclient/tests/unit/test_shell.py
index a2439f2..93b7ab3 100644
--- a/cinderclient/tests/unit/test_shell.py
+++ b/cinderclient/tests/unit/test_shell.py
@@ -214,6 +214,29 @@ class ShellTest(utils.TestCase):
self.assertEqual(False, _shell.cs.client.verify_cert)
+ @mock.patch('keystoneclient.session.Session.__init__',
+ side_effect=RuntimeError())
+ def test_http_client_with_cert(self, mock_session):
+ _shell = shell.OpenStackCinderShell()
+
+ # We crash the command after Session instantiation because this test
+ # focuses only on arguments provided to Session.__init__
+ args = '--os-cert', 'minnie', 'list'
+ self.assertRaises(RuntimeError, _shell.main, args)
+ mock_session.assert_called_once_with(cert='minnie', verify=mock.ANY)
+
+ @mock.patch('keystoneclient.session.Session.__init__',
+ side_effect=RuntimeError())
+ def test_http_client_with_cert_and_key(self, mock_session):
+ _shell = shell.OpenStackCinderShell()
+
+ # We crash the command after Session instantiation because this test
+ # focuses only on arguments provided to Session.__init__
+ args = '--os-cert', 'minnie', '--os-key', 'mickey', 'list'
+ self.assertRaises(RuntimeError, _shell.main, args)
+ mock_session.assert_called_once_with(cert=('minnie', 'mickey'),
+ verify=mock.ANY)
+
class CinderClientArgumentParserTest(utils.TestCase):