diff options
| author | Gorka Eguileor <geguileo@redhat.com> | 2017-08-04 18:07:24 +0200 |
|---|---|---|
| committer | Gorka Eguileor <geguileo@redhat.com> | 2017-08-04 18:10:50 +0200 |
| commit | ce1013d6b3b19baf81e393febe8a708cbe747f7b (patch) | |
| tree | 5780aa2c91a667cc0c28b35c7ddc4e132d4451b6 | |
| parent | 6498301b374f71e9df49135e109ba16c5e85bff4 (diff) | |
| download | python-cinderclient-ce1013d6b3b19baf81e393febe8a708cbe747f7b.tar.gz | |
Fix OS_AUTH_TYPE env var usage
Right now only deprecated OS_AUTH_SYSTEM environmental variable works to
set the authentication to noauth, the reason is that we have multiple
arguments writing on the same destination.
This patch fixes this by making both arguments have the same default
value, which is to use environmental variable OS_AUTH_TYPE if it has a
value or deprecated OS_AUTH_SYSTEM if not.
Closes-Bug: #1708687
Change-Id: I478fb0e628d4bebd4a1dc78c2559202916aa051f
| -rw-r--r-- | cinderclient/shell.py | 6 | ||||
| -rw-r--r-- | cinderclient/tests/unit/test_shell.py | 20 |
2 files changed, 24 insertions, 2 deletions
diff --git a/cinderclient/shell.py b/cinderclient/shell.py index 536ec3c..3ff9277 100644 --- a/cinderclient/shell.py +++ b/cinderclient/shell.py @@ -138,7 +138,8 @@ class OpenStackCinderShell(object): parser.add_argument('--os-auth-system', metavar='<os-auth-system>', dest='os_auth_type', - default=utils.env('OS_AUTH_SYSTEM'), + default=(utils.env('OS_AUTH_TYPE') or + utils.env('OS_AUTH_SYSTEM')), help=_('DEPRECATED! Use --os-auth-type. ' 'Defaults to env[OS_AUTH_SYSTEM].')) parser.add_argument('--os_auth_system', @@ -146,7 +147,8 @@ class OpenStackCinderShell(object): parser.add_argument('--os-auth-type', metavar='<os-auth-type>', dest='os_auth_type', - default=utils.env('OS_AUTH_TYPE'), + default=(utils.env('OS_AUTH_TYPE') or + utils.env('OS_AUTH_SYSTEM')), help=_('Defaults to env[OS_AUTH_TYPE].')) parser.add_argument('--os_auth_type', help=argparse.SUPPRESS) diff --git a/cinderclient/tests/unit/test_shell.py b/cinderclient/tests/unit/test_shell.py index 728dfd4..9930f58 100644 --- a/cinderclient/tests/unit/test_shell.py +++ b/cinderclient/tests/unit/test_shell.py @@ -72,6 +72,26 @@ class ShellTest(utils.TestCase): return out + def test_default_auth_env(self): + _shell = shell.OpenStackCinderShell() + args, __ = _shell.get_base_parser().parse_known_args([]) + self.assertEqual('', args.os_auth_type) + + def test_auth_type_env(self): + self.make_env(exclude='OS_PASSWORD', + include={'OS_AUTH_SYSTEM': 'non existent auth', + 'OS_AUTH_TYPE': 'noauth'}) + _shell = shell.OpenStackCinderShell() + args, __ = _shell.get_base_parser().parse_known_args([]) + self.assertEqual('noauth', args.os_auth_type) + + def test_auth_system_env(self): + self.make_env(exclude='OS_PASSWORD', + include={'OS_AUTH_SYSTEM': 'noauth'}) + _shell = shell.OpenStackCinderShell() + args, __ = _shell.get_base_parser().parse_known_args([]) + self.assertEqual('noauth', args.os_auth_type) + def test_help_unknown_command(self): self.assertRaises(exceptions.CommandError, self.shell, 'help foofoo') |
