diff options
author | Tim Burke <tim.burke@gmail.com> | 2023-03-10 21:39:57 -0800 |
---|---|---|
committer | Tim Burke <tim.burke@gmail.com> | 2023-03-23 20:32:23 -0700 |
commit | ee952c1bf250550d5da5b8a988e9e930edefce86 (patch) | |
tree | 71160f3d6d940ac1bb72a3e6185aae3731a0d243 /test/unit/test_shell.py | |
parent | 825145e9e6259d4a8d25502b2a6cc1257d9e86ba (diff) | |
download | python-swiftclient-ee952c1bf250550d5da5b8a988e9e930edefce86.tar.gz |
Ensure v*password auth_type correctly implies auth version
Change-Id: I787b0988b7518850f1e1f93ca269f39f8cdec15c
Diffstat (limited to 'test/unit/test_shell.py')
-rw-r--r-- | test/unit/test_shell.py | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/test/unit/test_shell.py b/test/unit/test_shell.py index 5e69f4a..e76f73c 100644 --- a/test/unit/test_shell.py +++ b/test/unit/test_shell.py @@ -2759,6 +2759,92 @@ class TestParsing(TestBase): swiftclient.shell.main(args) self._verify_opts(result[0], expected_opts, expected_os_opts, {}) + def test_os_auth_type_password_implies_version(self): + args = ["", "stat"] + env = { + 'OS_AUTH_URL': 'http://example.com/auth', + 'OS_AUTH_TYPE': 'v1password', + 'OS_USERNAME': 'user', + 'OS_PASSWORD': 'secret', + } + result = [None, None] + fake_command = self._make_fake_command(result) + with mock.patch.dict(os.environ, env): + with mock.patch('swiftclient.shell.st_stat', fake_command): + swiftclient.shell.main(args) + self._verify_opts(result[0], { + 'auth_version': '1.0', + 'user': 'user', + 'key': 'secret', + }, { + 'auth_url': 'http://example.com/auth', + 'auth_type': 'v1password', + 'username': 'user', + 'password': 'secret', + }, { + 'auth_url': 'http://example.com/auth', + 'auth_type': 'v1password', + 'username': 'user', + 'password': 'secret', + 'identity_api_version': '1.0', + }) + + env = { + 'OS_AUTH_URL': 'http://example.com/auth', + 'OS_AUTH_TYPE': 'v2password', + 'OS_USERNAME': 'user', + 'OS_PASSWORD': 'secret', + } + result = [None, None] + fake_command = self._make_fake_command(result) + with mock.patch.dict(os.environ, env): + with mock.patch('swiftclient.shell.st_stat', fake_command): + swiftclient.shell.main(args) + self._verify_opts(result[0], { + 'auth_version': '2.0', + 'user': 'user', + 'key': 'secret', + }, { + 'auth_url': 'http://example.com/auth', + 'auth_type': 'v2password', + 'username': 'user', + 'password': 'secret', + }, { + 'auth_url': 'http://example.com/auth', + 'auth_type': 'v2password', + 'username': 'user', + 'password': 'secret', + 'identity_api_version': '2.0', + }) + + env = { + 'OS_AUTH_URL': 'http://example.com/auth', + 'OS_AUTH_TYPE': 'v3password', + 'OS_USERNAME': 'user', + 'OS_PASSWORD': 'secret', + } + result = [None, None] + fake_command = self._make_fake_command(result) + with mock.patch.dict(os.environ, env): + with mock.patch('swiftclient.shell.st_stat', fake_command): + swiftclient.shell.main(args) + self._verify_opts(result[0], { + 'auth_version': '3', + 'user': 'user', + 'key': 'secret', + }, { + 'auth_url': 'http://example.com/auth', + 'auth_type': 'v3password', + 'username': 'user', + 'password': 'secret', + }, { + 'auth_url': 'http://example.com/auth', + 'auth_type': 'v3password', + 'username': 'user', + 'password': 'secret', + 'identity_api_version': '3', + }) + def test_args_v3(self): opts = {"auth_version": "3"} os_opts = {"password": "secret", |