Skip to content

Commit ce1013d

Browse files
committed
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
1 parent 6498301 commit ce1013d

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

cinderclient/shell.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,17 @@ def get_base_parser(self):
138138
parser.add_argument('--os-auth-system',
139139
metavar='<os-auth-system>',
140140
dest='os_auth_type',
141-
default=utils.env('OS_AUTH_SYSTEM'),
141+
default=(utils.env('OS_AUTH_TYPE') or
142+
utils.env('OS_AUTH_SYSTEM')),
142143
help=_('DEPRECATED! Use --os-auth-type. '
143144
'Defaults to env[OS_AUTH_SYSTEM].'))
144145
parser.add_argument('--os_auth_system',
145146
help=argparse.SUPPRESS)
146147
parser.add_argument('--os-auth-type',
147148
metavar='<os-auth-type>',
148149
dest='os_auth_type',
149-
default=utils.env('OS_AUTH_TYPE'),
150+
default=(utils.env('OS_AUTH_TYPE') or
151+
utils.env('OS_AUTH_SYSTEM')),
150152
help=_('Defaults to env[OS_AUTH_TYPE].'))
151153
parser.add_argument('--os_auth_type',
152154
help=argparse.SUPPRESS)

cinderclient/tests/unit/test_shell.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,26 @@ def shell(self, argstr):
7272

7373
return out
7474

75+
def test_default_auth_env(self):
76+
_shell = shell.OpenStackCinderShell()
77+
args, __ = _shell.get_base_parser().parse_known_args([])
78+
self.assertEqual('', args.os_auth_type)
79+
80+
def test_auth_type_env(self):
81+
self.make_env(exclude='OS_PASSWORD',
82+
include={'OS_AUTH_SYSTEM': 'non existent auth',
83+
'OS_AUTH_TYPE': 'noauth'})
84+
_shell = shell.OpenStackCinderShell()
85+
args, __ = _shell.get_base_parser().parse_known_args([])
86+
self.assertEqual('noauth', args.os_auth_type)
87+
88+
def test_auth_system_env(self):
89+
self.make_env(exclude='OS_PASSWORD',
90+
include={'OS_AUTH_SYSTEM': 'noauth'})
91+
_shell = shell.OpenStackCinderShell()
92+
args, __ = _shell.get_base_parser().parse_known_args([])
93+
self.assertEqual('noauth', args.os_auth_type)
94+
7595
def test_help_unknown_command(self):
7696
self.assertRaises(exceptions.CommandError, self.shell, 'help foofoo')
7797

0 commit comments

Comments
 (0)