Add a fixture method to add your own token data

The fixture has an add_token_data method which lets you provide common
token information, however there is no way to do more adanced tokens
through that interface or control the service catalog.

Rather than overload the simple method add a more low level method that
will let you add a token that you created using keystoneauth1 fixtures
yourself.

Change-Id: I6351b5980d7d87b00caed351987bf46e30cdf036
This commit is contained in:
Jamie Lennox 2016-06-10 15:16:21 +10:00
parent cc58b62f11
commit b5a2535326
1 changed files with 17 additions and 1 deletions

View File

@ -71,7 +71,23 @@ class AuthTokenFixture(fixtures.Fixture):
project_domain_name=project_domain_name)
for role in role_list:
token.add_role(name=role)
self._token_data[token_id] = token
self.add_token(token, token_id=token_id)
@positional()
def add_token(self, token_data, token_id=None):
"""Add an existing token to the middleware.
:param token_data: token data to add to the fixture
:type token_data: dict
:param token_id: the token ID to add this token as
:type token_id: str
:returns: The token_id that the token was added as.
:rtype: str
"""
if not token_id:
token_id = uuid.uuid4().hex
self._token_data[token_id] = token_data
return token_id
def fetch_token(self, token):
"""Low level replacement of fetch_token for AuthProtocol."""