summaryrefslogtreecommitdiff
path: root/openstackclient/tests/test_shell.py
diff options
context:
space:
mode:
authorDean Troyer <dtroyer@gmail.com>2015-05-01 12:25:58 -0500
committerDean Troyer <dtroyer@gmail.com>2015-05-28 18:01:49 -0500
commit2c4b87869be7afb26d6190bb4fd3301eb4061604 (patch)
treed51c6415d43733e3cde77299497497111328dad4 /openstackclient/tests/test_shell.py
parent211c14c638b9bf393932be42d4f04a4dd12a84bc (diff)
downloadpython-openstackclient-2c4b87869be7afb26d6190bb4fd3301eb4061604.tar.gz
Add cli tests for --verify and friends
The tests that will change after the verify-always-true bug is fixed are currently commented out. The commented asserts show where we want to go. Also fixes --verify parser value Change-Id: I891e3ead5fc3da3ed2ecba5d2befd9e910778655
Diffstat (limited to 'openstackclient/tests/test_shell.py')
-rw-r--r--openstackclient/tests/test_shell.py54
1 files changed, 53 insertions, 1 deletions
diff --git a/openstackclient/tests/test_shell.py b/openstackclient/tests/test_shell.py
index a3250f17..a37d2ac8 100644
--- a/openstackclient/tests/test_shell.py
+++ b/openstackclient/tests/test_shell.py
@@ -527,13 +527,65 @@ class TestShellCli(TestShell):
super(TestShellCli, self).tearDown()
os.environ = self.orig_env
- def test_shell_args(self):
+ def test_shell_args_no_options(self):
_shell = make_shell()
with mock.patch("openstackclient.shell.OpenStackShell.initialize_app",
self.app):
fake_execute(_shell, "list user")
self.app.assert_called_with(["list", "user"])
+ def test_shell_args_ca_options(self):
+ _shell = make_shell()
+
+ # NOTE(dtroyer): The commented out asserts below are the desired
+ # behaviour and will be uncommented when the
+ # handling for --verify and --insecure is fixed.
+
+ # Default
+ fake_execute(_shell, "list user")
+ self.assertIsNone(_shell.options.verify)
+ self.assertIsNone(_shell.options.insecure)
+ self.assertEqual('', _shell.options.os_cacert)
+ self.assertTrue(_shell.verify)
+
+ # --verify
+ fake_execute(_shell, "--verify list user")
+ self.assertTrue(_shell.options.verify)
+ self.assertIsNone(_shell.options.insecure)
+ self.assertEqual('', _shell.options.os_cacert)
+ self.assertTrue(_shell.verify)
+
+ # --insecure
+ fake_execute(_shell, "--insecure list user")
+ self.assertIsNone(_shell.options.verify)
+ self.assertTrue(_shell.options.insecure)
+ self.assertEqual('', _shell.options.os_cacert)
+ self.assertFalse(_shell.verify)
+
+ # --os-cacert
+ fake_execute(_shell, "--os-cacert foo list user")
+ self.assertIsNone(_shell.options.verify)
+ self.assertIsNone(_shell.options.insecure)
+ self.assertEqual('foo', _shell.options.os_cacert)
+ self.assertTrue(_shell.verify)
+
+ # --os-cacert and --verify
+ fake_execute(_shell, "--os-cacert foo --verify list user")
+ self.assertTrue(_shell.options.verify)
+ self.assertIsNone(_shell.options.insecure)
+ self.assertEqual('foo', _shell.options.os_cacert)
+ self.assertTrue(_shell.verify)
+
+ # --os-cacert and --insecure
+ # NOTE(dtroyer): This really is a bogus combination, the default is
+ # to follow the requests.Session convention and let
+ # --os-cacert override --insecure
+ fake_execute(_shell, "--os-cacert foo --insecure list user")
+ self.assertIsNone(_shell.options.verify)
+ self.assertTrue(_shell.options.insecure)
+ self.assertEqual('foo', _shell.options.os_cacert)
+ self.assertTrue(_shell.verify)
+
def test_default_env(self):
flag = ""
kwargs = {