summaryrefslogtreecommitdiff
path: root/openstackclient/tests
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-02-21 04:31:50 +0000
committerGerrit Code Review <review@openstack.org>2016-02-21 04:31:51 +0000
commit867bcb0db8742fd2daa5c91dfd3c164ac4178f18 (patch)
treeab6312faf2d924879996e74bdfd5492b4f459598 /openstackclient/tests
parentf4ca06cad6348b2a00d72d65c7a1c2f56e8df1d4 (diff)
parent41e1bd0be64e15a5e0c12b45bdf3dcde5fabf244 (diff)
downloadpython-openstackclient-867bcb0db8742fd2daa5c91dfd3c164ac4178f18.tar.gz
Merge "Support unscoped token request"
Diffstat (limited to 'openstackclient/tests')
-rw-r--r--openstackclient/tests/common/test_clientmanager.py25
-rw-r--r--openstackclient/tests/identity/v2_0/fakes.py6
-rw-r--r--openstackclient/tests/identity/v2_0/test_token.py22
-rw-r--r--openstackclient/tests/identity/v3/fakes.py6
-rw-r--r--openstackclient/tests/identity/v3/test_token.py21
5 files changed, 80 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()
diff --git a/openstackclient/tests/identity/v2_0/fakes.py b/openstackclient/tests/identity/v2_0/fakes.py
index 6688606a..565606c1 100644
--- a/openstackclient/tests/identity/v2_0/fakes.py
+++ b/openstackclient/tests/identity/v2_0/fakes.py
@@ -80,6 +80,12 @@ TOKEN = {
'user_id': user_id,
}
+UNSCOPED_TOKEN = {
+ 'expires': token_expires,
+ 'id': token_id,
+ 'user_id': user_id,
+}
+
endpoint_name = service_name
endpoint_adminurl = 'https://admin.example.com/v2/UUID'
endpoint_region = 'RegionOne'
diff --git a/openstackclient/tests/identity/v2_0/test_token.py b/openstackclient/tests/identity/v2_0/test_token.py
index 7687a063..c90477f9 100644
--- a/openstackclient/tests/identity/v2_0/test_token.py
+++ b/openstackclient/tests/identity/v2_0/test_token.py
@@ -60,6 +60,28 @@ class TestTokenIssue(TestToken):
)
self.assertEqual(datalist, data)
+ def test_token_issue_with_unscoped_token(self):
+ # make sure we return an unscoped token
+ self.sc_mock.get_token.return_value = identity_fakes.UNSCOPED_TOKEN
+
+ arglist = []
+ verifylist = []
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ # DisplayCommandBase.take_action() returns two tuples
+ columns, data = self.cmd.take_action(parsed_args)
+
+ self.sc_mock.get_token.assert_called_with()
+
+ collist = ('expires', 'id', 'user_id')
+ self.assertEqual(collist, columns)
+ datalist = (
+ identity_fakes.token_expires,
+ identity_fakes.token_id,
+ identity_fakes.user_id,
+ )
+ self.assertEqual(datalist, data)
+
class TestTokenRevoke(TestToken):
diff --git a/openstackclient/tests/identity/v3/fakes.py b/openstackclient/tests/identity/v3/fakes.py
index a06802c5..420604f1 100644
--- a/openstackclient/tests/identity/v3/fakes.py
+++ b/openstackclient/tests/identity/v3/fakes.py
@@ -244,6 +244,12 @@ TRUST = {
token_expires = '2014-01-01T00:00:00Z'
token_id = 'tttttttt-tttt-tttt-tttt-tttttttttttt'
+UNSCOPED_TOKEN = {
+ 'expires': token_expires,
+ 'id': token_id,
+ 'user_id': user_id,
+}
+
TOKEN_WITH_PROJECT_ID = {
'expires': token_expires,
'id': token_id,
diff --git a/openstackclient/tests/identity/v3/test_token.py b/openstackclient/tests/identity/v3/test_token.py
index b051aacb..80c397bc 100644
--- a/openstackclient/tests/identity/v3/test_token.py
+++ b/openstackclient/tests/identity/v3/test_token.py
@@ -85,6 +85,27 @@ class TestTokenIssue(TestToken):
)
self.assertEqual(datalist, data)
+ def test_token_issue_with_unscoped(self):
+ arglist = []
+ verifylist = []
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+ self.sc_mock.get_token.return_value = \
+ identity_fakes.UNSCOPED_TOKEN
+
+ # DisplayCommandBase.take_action() returns two tuples
+ columns, data = self.cmd.take_action(parsed_args)
+
+ self.sc_mock.get_token.assert_called_with()
+
+ collist = ('expires', 'id', 'user_id')
+ self.assertEqual(collist, columns)
+ datalist = (
+ identity_fakes.token_expires,
+ identity_fakes.token_id,
+ identity_fakes.user_id,
+ )
+ self.assertEqual(datalist, data)
+
class TestTokenRevoke(TestToken):