diff --git a/cinderclient/shell.py b/cinderclient/shell.py index 536ec3c0a..3ff9277cf 100644 --- a/cinderclient/shell.py +++ b/cinderclient/shell.py @@ -138,7 +138,8 @@ class OpenStackCinderShell(object): parser.add_argument('--os-auth-system', metavar='', 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='', 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 728dfd42d..9930f58f9 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')