Correct fake V3 token responses
A V3 token always contains audit_ids. The V3 token catalog has region_id in addition to region (region is deprecated). Also, the V3 token has password_expires_at in the user. See http://developer.openstack.org/api-ref/identity/v3/index.html?expanded=password-authentication-with-scoped-authorization-detail Change-Id: I426cf216cf6a8e348e6f0343e0f71b9766919f60
This commit is contained in:
parent
6912b89306
commit
aef9499dc0
@ -55,6 +55,7 @@ ALT_IDENTITY_V2_RESPONSE = {
|
||||
},
|
||||
"user": {
|
||||
"id": "fake_alt_user_id",
|
||||
"password_expires_at": None,
|
||||
},
|
||||
"serviceCatalog": CATALOG_V2,
|
||||
},
|
||||
@ -71,6 +72,7 @@ IDENTITY_V2_RESPONSE = {
|
||||
},
|
||||
"user": {
|
||||
"id": "fake_user_id",
|
||||
"password_expires_at": None,
|
||||
},
|
||||
"serviceCatalog": CATALOG_V2,
|
||||
},
|
||||
@ -83,18 +85,21 @@ COMPUTE_ENDPOINTS_V3 = {
|
||||
"id": "first_compute_fake_service",
|
||||
"interface": "public",
|
||||
"region": "NoMatchRegion",
|
||||
"region_id": "NoMatchRegion",
|
||||
"url": "http://fake_url/v3/first_endpoint/api"
|
||||
},
|
||||
{
|
||||
"id": "second_fake_service",
|
||||
"interface": "public",
|
||||
"region": "FakeRegion",
|
||||
"region_id": "FakeRegion",
|
||||
"url": "http://fake_url/v3/second_endpoint/api"
|
||||
},
|
||||
{
|
||||
"id": "third_fake_service",
|
||||
"interface": "admin",
|
||||
"region": "MiddleEarthRegion",
|
||||
"region_id": "MiddleEarthRegion",
|
||||
"url": "http://fake_url/v3/third_endpoint/api"
|
||||
}
|
||||
|
||||
@ -108,6 +113,7 @@ CATALOG_V3 = [COMPUTE_ENDPOINTS_V3, ]
|
||||
|
||||
IDENTITY_V3_RESPONSE = {
|
||||
"token": {
|
||||
"audit_ids": ["ny5LA5YXToa_mAVO8Hnupw", "9NPTvsRDSkmsW61abP978Q"],
|
||||
"methods": [
|
||||
"token",
|
||||
"password"
|
||||
@ -127,7 +133,8 @@ IDENTITY_V3_RESPONSE = {
|
||||
"name": "domain_name"
|
||||
},
|
||||
"id": "fake_user_id",
|
||||
"name": "username"
|
||||
"name": "username",
|
||||
"password_expires_at": None,
|
||||
},
|
||||
"issued_at": "2013-05-29T16:55:21.468960Z",
|
||||
"catalog": CATALOG_V3
|
||||
@ -136,6 +143,7 @@ IDENTITY_V3_RESPONSE = {
|
||||
|
||||
IDENTITY_V3_RESPONSE_DOMAIN_SCOPE = {
|
||||
"token": {
|
||||
"audit_ids": ["ny5LA5YXToa_mAVO8Hnupw", "9NPTvsRDSkmsW61abP978Q"],
|
||||
"methods": [
|
||||
"token",
|
||||
"password"
|
||||
@ -151,7 +159,8 @@ IDENTITY_V3_RESPONSE_DOMAIN_SCOPE = {
|
||||
"name": "domain_name"
|
||||
},
|
||||
"id": "fake_user_id",
|
||||
"name": "username"
|
||||
"name": "username",
|
||||
"password_expires_at": None,
|
||||
},
|
||||
"issued_at": "2013-05-29T16:55:21.468960Z",
|
||||
"catalog": CATALOG_V3
|
||||
@ -160,6 +169,7 @@ IDENTITY_V3_RESPONSE_DOMAIN_SCOPE = {
|
||||
|
||||
IDENTITY_V3_RESPONSE_NO_SCOPE = {
|
||||
"token": {
|
||||
"audit_ids": ["ny5LA5YXToa_mAVO8Hnupw", "9NPTvsRDSkmsW61abP978Q"],
|
||||
"methods": [
|
||||
"token",
|
||||
"password"
|
||||
@ -171,7 +181,8 @@ IDENTITY_V3_RESPONSE_NO_SCOPE = {
|
||||
"name": "domain_name"
|
||||
},
|
||||
"id": "fake_user_id",
|
||||
"name": "username"
|
||||
"name": "username",
|
||||
"password_expires_at": None,
|
||||
},
|
||||
"issued_at": "2013-05-29T16:55:21.468960Z",
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ from tempest.lib.common import rest_client
|
||||
from tempest.lib import exceptions
|
||||
from tempest.lib.services.identity.v3 import token_client
|
||||
from tempest.tests import base
|
||||
from tempest.tests.lib import fake_http
|
||||
from tempest.tests.lib import fake_identity
|
||||
|
||||
|
||||
class TestTokenClientV3(base.TestCase):
|
||||
@ -31,10 +31,8 @@ class TestTokenClientV3(base.TestCase):
|
||||
|
||||
def test_auth(self):
|
||||
token_client_v3 = token_client.V3TokenClient('fake_url')
|
||||
response = fake_http.fake_http_response(
|
||||
None, status=201,
|
||||
)
|
||||
body = {'access': {'token': 'fake_token'}}
|
||||
response, body_text = fake_identity._fake_v3_response(None, None)
|
||||
body = json.loads(body_text)
|
||||
|
||||
with mock.patch.object(token_client_v3, 'post') as post_mock:
|
||||
post_mock.return_value = response, body
|
||||
@ -60,10 +58,8 @@ class TestTokenClientV3(base.TestCase):
|
||||
|
||||
def test_auth_with_project_id_and_domain_id(self):
|
||||
token_client_v3 = token_client.V3TokenClient('fake_url')
|
||||
response = fake_http.fake_http_response(
|
||||
None, status=201,
|
||||
)
|
||||
body = {'access': {'token': 'fake_token'}}
|
||||
response, body_text = fake_identity._fake_v3_response(None, None)
|
||||
body = json.loads(body_text)
|
||||
|
||||
with mock.patch.object(token_client_v3, 'post') as post_mock:
|
||||
post_mock.return_value = response, body
|
||||
@ -103,10 +99,8 @@ class TestTokenClientV3(base.TestCase):
|
||||
|
||||
def test_auth_with_tenant(self):
|
||||
token_client_v3 = token_client.V3TokenClient('fake_url')
|
||||
response = fake_http.fake_http_response(
|
||||
None, status=201,
|
||||
)
|
||||
body = {'access': {'token': 'fake_token'}}
|
||||
response, body_text = fake_identity._fake_v3_response(None, None)
|
||||
body = json.loads(body_text)
|
||||
|
||||
with mock.patch.object(token_client_v3, 'post') as post_mock:
|
||||
post_mock.return_value = response, body
|
||||
@ -138,13 +132,10 @@ class TestTokenClientV3(base.TestCase):
|
||||
|
||||
def test_request_with_str_body(self):
|
||||
token_client_v3 = token_client.V3TokenClient('fake_url')
|
||||
response = fake_http.fake_http_response(
|
||||
None, status=200,
|
||||
)
|
||||
body = str('{"access": {"token": "fake_token"}}')
|
||||
|
||||
with mock.patch.object(token_client_v3, 'raw_request') as mock_raw_r:
|
||||
mock_raw_r.return_value = response, body
|
||||
mock_raw_r.return_value = (
|
||||
fake_identity._fake_v3_response(None, None))
|
||||
resp, body = token_client_v3.request('GET', 'fake_uri')
|
||||
|
||||
self.assertIsInstance(body, dict)
|
||||
@ -152,10 +143,8 @@ class TestTokenClientV3(base.TestCase):
|
||||
def test_request_with_bytes_body(self):
|
||||
token_client_v3 = token_client.V3TokenClient('fake_url')
|
||||
|
||||
response = fake_http.fake_http_response(
|
||||
None, status=200,
|
||||
)
|
||||
body = b'{"access": {"token": "fake_token"}}'
|
||||
response, body_text = fake_identity._fake_v3_response(None, None)
|
||||
body = body_text.encode('utf-8')
|
||||
|
||||
with mock.patch.object(token_client_v3, 'raw_request') as mock_raw_r:
|
||||
mock_raw_r.return_value = response, body
|
||||
|
Loading…
x
Reference in New Issue
Block a user