summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlistair Coles <alistair.coles@hpe.com>2016-05-05 15:25:16 +0100
committerAlistair Coles <alistair.coles@hpe.com>2016-05-05 15:25:16 +0100
commita0d65e4ccddffbf2b1596332ef67733583554bbc (patch)
tree6c59829569cbad1e59984dd0158c6fca92c810e4
parentc3766319b93d60e30f55747f6cfc9ca915ff603c (diff)
downloadpython-swiftclient-a0d65e4ccddffbf2b1596332ef67733583554bbc.tar.gz
Tighten up testing for sloppy auth version
The existing test that os-identity-api-version=2 would result in the correct auth_version=2.0 (note 2 -> 2.0) does not verify the sloppy version handling code path. When auth, key and user options are all missing the auth version is always set to 2.0 so the test will always pass. Adding auth, key and user options to the test command will cause the test to verify that the os-identity-api-version option was used and mapped to 2.0. Change-Id: Ifa10cd2b8bf81c082d5e3fa846f993871194fea0
-rw-r--r--tests/unit/test_shell.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/tests/unit/test_shell.py b/tests/unit/test_shell.py
index f921721..faf6058 100644
--- a/tests/unit/test_shell.py
+++ b/tests/unit/test_shell.py
@@ -1528,7 +1528,7 @@ class TestParsing(TestBase):
"auth_url": "http://example.com:5000/v3",
"identity-api-version": "3.0"}
- # check os_identity_api_version is sufficient in place of auth_version
+ # check os_identity_api_version=3.0 is mapped to auth_version=3
args = _make_args("stat", {}, os_opts, '-')
result = [None, None]
fake_command = self._make_fake_command(result)
@@ -1541,13 +1541,19 @@ class TestParsing(TestBase):
"auth_url": "http://example.com:5000/v3"}
self._verify_opts(result[0], expected_opts, expected_os_opts, {})
+ # check os_identity_api_version=2 is mapped to auth_version=2.0
+ # A somewhat contrived scenario - we need to pass in the v1 style opts
+ # to prevent auth version defaulting to 2.0 due to lack of v1 style
+ # options. That way we can actually verify that the sloppy 2 was
+ # interpreted and mapped to 2.0
os_opts = {"password": "secret",
"username": "user",
"auth_url": "http://example.com:5000/v2.0",
"identity-api-version": "2"}
-
- # check os_identity_api_version is sufficient in place of auth_version
- args = _make_args("stat", {}, os_opts, '-')
+ opts = {"key": "secret",
+ "user": "user",
+ "auth": "http://example.com:5000/v2.0"}
+ args = _make_args("stat", opts, os_opts, '-')
result = [None, None]
fake_command = self._make_fake_command(result)
with mock.patch.dict(os.environ, {}):