Fix gate error caused by mocked URLs

In keystoneauth a workaround was implemented for when the discovery
document has an invalid scheme and host for its URLs[1]. This broke
keystonemiddleware's tests, revealing that keystonemiddleware was, in
one case, validating the wrong URL, and in another mocking the wrong
one. This patch updates the tests so that they are more accurately
representing how keystoneauth works.

Why should we change it here instead of reverting the keystoneauth
change? The URLs in the discovery document aren't validated in real
life, so the only URLs that can be trusted are the ones the user has
accessed, such as the auth URL. Keystoneauth is right to fix the URLs,
and the bad mocks in keystonemiddleware are only evidence that the tests
were wrong, not that the mocked URLs would have worked in real life.

[1] https://review.openstack.org/#/c/494194

Closes-Bug: Closes-bug: #1718945
Co-Authored-By: Colleen Murphy <colleen@gazlene.net>

Change-Id: I94d6dd1839bd1f662e70c5fb739695685e839a82
This commit is contained in:
Tin Lam 2017-09-15 13:25:46 -05:00
parent cd598a4f83
commit 04735348de
2 changed files with 3 additions and 3 deletions

View File

@ -2442,7 +2442,7 @@ class AuthProtocolLoadingTests(BaseAuthTokenMiddlewareTest):
s = admin_token.add_service('identity', name='keystone')
s.add_standard_endpoints(admin=self.KEYSTONE_URL)
self.requests_mock.post(self.DISC_URL + '/v3/auth/tokens',
self.requests_mock.post('%s/v3/auth/tokens' % self.AUTH_URL,
json=admin_token,
headers={'X-Subject-Token': admin_token_id})
@ -2454,7 +2454,7 @@ class AuthProtocolLoadingTests(BaseAuthTokenMiddlewareTest):
request_headers = {'X-Subject-Token': user_token_id,
'X-Auth-Token': admin_token_id}
self.requests_mock.get(self.CRUD_URL + '/v3/auth/tokens',
self.requests_mock.get('%s/v3/auth/tokens' % self.KEYSTONE_BASE_URL,
request_headers=request_headers,
json=user_token,
headers={'X-Subject-Token': uuid.uuid4().hex})

View File

@ -252,7 +252,7 @@ class Examples(fixtures.Fixture):
SERVICE_ROLE_NAME2 = 'service_role2'
self.SERVICE_TYPE = 'identity'
self.UNVERSIONED_SERVICE_URL = 'http://keystone.server:5000/'
self.UNVERSIONED_SERVICE_URL = 'https://keystone.example.com:1234/'
self.SERVICE_URL = self.UNVERSIONED_SERVICE_URL + 'v2.0'
# Old Tokens