summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Warren <jswarren@us.ibm.com>2016-02-06 09:58:10 -0500
committerJohn Warren <jswarren@us.ibm.com>2016-02-10 07:10:24 -0500
commit6ddbb9e70dccf0e661a2ba43aa311639f9c9827c (patch)
treed3b33af84b2708c2dc2ebd5d07241059861654ec
parent1abd727c1153e82b02bb93c12051065e82a81a2c (diff)
downloadtempest-lib-6ddbb9e70dccf0e661a2ba43aa311639f9c9827c.tar.gz
Fix project domain problem in v3 token client
The project domain (name or ID) is omitted in auth requests when the project ID is specified. This change fixes the issue. Change-Id: I3d970acd9b5c61ee3436689f940a5e92b10ae299 Closes-Bug: #1542655
-rw-r--r--tempest_lib/services/identity/v3/token_client.py8
-rw-r--r--tempest_lib/tests/services/identity/v3/test_token_client.py38
2 files changed, 42 insertions, 4 deletions
diff --git a/tempest_lib/services/identity/v3/token_client.py b/tempest_lib/services/identity/v3/token_client.py
index c030bba..868b4f7 100644
--- a/tempest_lib/services/identity/v3/token_client.py
+++ b/tempest_lib/services/identity/v3/token_client.py
@@ -105,10 +105,10 @@ class V3TokenClient(rest_client.RestClient):
elif project_name:
_project['name'] = project_name
- if project_domain_id is not None:
- _project['domain'] = {'id': project_domain_id}
- elif project_domain_name is not None:
- _project['domain'] = {'name': project_domain_name}
+ if project_domain_id is not None:
+ _project['domain'] = {'id': project_domain_id}
+ elif project_domain_name is not None:
+ _project['domain'] = {'name': project_domain_name}
creds['auth']['scope'] = dict(project=_project)
elif domain_id:
diff --git a/tempest_lib/tests/services/identity/v3/test_token_client.py b/tempest_lib/tests/services/identity/v3/test_token_client.py
index 44cc8e2..b3a8b28 100644
--- a/tempest_lib/tests/services/identity/v3/test_token_client.py
+++ b/tempest_lib/tests/services/identity/v3/test_token_client.py
@@ -57,6 +57,44 @@ class TestTokenClientV2(base.TestCase):
post_mock.mock.assert_called_once_with('fake_url/auth/tokens',
body=req_dict)
+ def test_auth_with_project_id_and_domain_id(self):
+ token_client_v3 = token_client.V3TokenClient('fake_url')
+ post_mock = self.useFixture(mockpatch.PatchObject(
+ token_client_v3, 'post', return_value=self.fake_201_http.request(
+ 'fake_url', body={'access': {'token': 'fake_token'}})))
+ resp = token_client_v3.auth(
+ username='fake_user', password='fake_pass',
+ project_id='fcac2a055a294e4c82d0a9c21c620eb4',
+ user_domain_id='14f4a9a99973404d8c20ba1d2af163ff',
+ project_domain_id='291f63ae9ac54ee292ca09e5f72d9676')
+ self.assertIsInstance(resp, rest_client.ResponseBody)
+ req_dict = json.dumps({
+ 'auth': {
+ 'identity': {
+ 'methods': ['password'],
+ 'password': {
+ 'user': {
+ 'name': 'fake_user',
+ 'password': 'fake_pass',
+ 'domain': {
+ 'id': '14f4a9a99973404d8c20ba1d2af163ff'
+ }
+ }
+ }
+ },
+ 'scope': {
+ 'project': {
+ 'id': 'fcac2a055a294e4c82d0a9c21c620eb4',
+ 'domain': {
+ 'id': '291f63ae9ac54ee292ca09e5f72d9676'
+ }
+ }
+ }
+ }
+ }, sort_keys=True)
+ post_mock.mock.assert_called_once_with('fake_url/auth/tokens',
+ body=req_dict)
+
def test_auth_with_tenant(self):
token_client_v2 = token_client.V3TokenClient('fake_url')
post_mock = self.useFixture(mockpatch.PatchObject(