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
This commit is contained in:
Alistair Coles 2016-05-05 15:25:16 +01:00
parent c3766319b9
commit a0d65e4ccd

@ -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, {}):