Skip to content

Commit

Permalink
Merge "Fix OS_AUTH_TYPE env var usage"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and openstack-gerrit committed Oct 19, 2017
2 parents f6f5a70 + ce1013d commit a836434
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cinderclient/shell.py
Expand Up @@ -140,15 +140,17 @@ def get_base_parser(self):
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',
help=argparse.SUPPRESS)
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)
Expand Down
20 changes: 20 additions & 0 deletions cinderclient/tests/unit/test_shell.py
Expand Up @@ -72,6 +72,26 @@ def shell(self, argstr):

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')

Expand Down

0 comments on commit a836434

Please sign in to comment.