Warn user about unsupported API version
Prints a warning when the user tries to use an unsupported API. Also provides a test case to check it still does fall back to 2.0. Change-Id: Idabd150f52d27a9d065cf570f6367459126f98be Closes-bug: #1256987
This commit is contained in:
@@ -431,6 +431,10 @@ class OpenStackIdentityShell(object):
|
|||||||
"2.0": shell_v2_0.CLIENT_CLASS,
|
"2.0": shell_v2_0.CLIENT_CLASS,
|
||||||
}[version]
|
}[version]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
if version:
|
||||||
|
msg = ('WARNING: unsupported identity-api-version %s, '
|
||||||
|
'falling back to 2.0' % version)
|
||||||
|
print(msg)
|
||||||
return shell_v2_0.CLIENT_CLASS
|
return shell_v2_0.CLIENT_CLASS
|
||||||
|
|
||||||
def do_bash_completion(self, args):
|
def do_bash_completion(self, args):
|
||||||
|
@@ -200,6 +200,11 @@ class ShellTest(utils.TestCase):
|
|||||||
'wilma', 'betty', '2.0', True, '500', True)
|
'wilma', 'betty', '2.0', True, '500', True)
|
||||||
self.assertTrue(all([x == y for x, y in zip(actual, expect)]))
|
self.assertTrue(all([x == y for x, y in zip(actual, expect)]))
|
||||||
|
|
||||||
|
# Test os-identity-api-version fall back to 2.0
|
||||||
|
shell('--os-identity-api-version 3.0 user-list')
|
||||||
|
assert do_tenant_mock.called
|
||||||
|
self.assertTrue(b.os_identity_api_version, '2.0')
|
||||||
|
|
||||||
def test_shell_user_create_args(self):
|
def test_shell_user_create_args(self):
|
||||||
"""Test user-create args."""
|
"""Test user-create args."""
|
||||||
do_uc_mock = mock.MagicMock()
|
do_uc_mock = mock.MagicMock()
|
||||||
|
Reference in New Issue
Block a user