diff options
| author | guang-yee <guang.yee@hpe.com> | 2016-02-08 11:16:24 -0800 |
|---|---|---|
| committer | guang-yee <guang.yee@hpe.com> | 2016-02-19 16:07:13 -0800 |
| commit | 41e1bd0be64e15a5e0c12b45bdf3dcde5fabf244 (patch) | |
| tree | 0d5f55b0495c3208f981b7a180619d8d6b02d3a2 /openstackclient/tests/common/test_clientmanager.py | |
| parent | ab6ba385a2c292a7a906390ad911db8c59811a07 (diff) | |
| download | python-openstackclient-41e1bd0be64e15a5e0c12b45bdf3dcde5fabf244.tar.gz | |
Support unscoped token request
Make scope check optional for the "token issue" command as unscoped token is
a valid Keystone V2/V3 API.
Change-Id: Ie1cded4dbfdafd3a78c0ebdf89e3f66762509930
Closes-Bug: #1543214
Diffstat (limited to 'openstackclient/tests/common/test_clientmanager.py')
| -rw-r--r-- | openstackclient/tests/common/test_clientmanager.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/openstackclient/tests/common/test_clientmanager.py b/openstackclient/tests/common/test_clientmanager.py index 523f79a3..ef46f61c 100644 --- a/openstackclient/tests/common/test_clientmanager.py +++ b/openstackclient/tests/common/test_clientmanager.py @@ -325,3 +325,28 @@ class TestClientManager(utils.TestCase): exc.CommandError, client_manager.setup_auth, ) + + @mock.patch('openstackclient.api.auth.check_valid_auth_options') + def test_client_manager_auth_setup_once(self, check_auth_options_func): + client_manager = clientmanager.ClientManager( + cli_options=FakeOptions( + auth=dict( + auth_url=fakes.AUTH_URL, + username=fakes.USERNAME, + password=fakes.PASSWORD, + project_name=fakes.PROJECT_NAME, + ), + ), + api_version=API_VERSION, + verify=False, + ) + self.assertFalse(client_manager._auth_setup_completed) + client_manager.setup_auth() + self.assertTrue(check_auth_options_func.called) + self.assertTrue(client_manager._auth_setup_completed) + + # now make sure we don't do auth setup the second time around + # by checking whether check_valid_auth_options() gets called again + check_auth_options_func.reset_mock() + client_manager.auth_ref + check_auth_options_func.assert_not_called() |
