Enhance tempest client for keystone v3 token APIs.

Although some of the APIs have been implemented,
adding the below missing one:

check_token_existence(): to validate a v3 token head

Change-Id: I0b95a19162456cbaf524ea6691e7e28c151c6ada
Co-Authored-By: Pradeep Kumar <pk5294@att.com>
Co-Authored-By: Nishant Kumar <nk613n@att.com>
Closes-Bug: #1691044
This commit is contained in:
Pramod Kumar Singh 2017-06-02 16:21:10 +05:30
parent a8006de318
commit 1e8a0ed3e5
4 changed files with 22 additions and 1 deletions

View File

@ -0,0 +1,5 @@
---
features:
- |
Enhances the v3 identity client with the ``check_token_existence``
endpoint, allowing users to check the existence of tokens

View File

@ -39,6 +39,7 @@ class TokensV3TestJSON(base.BaseIdentityV3AdminTest):
resp = self.token.auth(user_id=user['id'],
password=u_password).response
subject_token = resp['x-subject-token']
self.client.check_token_existence(subject_token)
# Perform GET Token
token_details = self.client.show_token(subject_token)['token']
self.assertEqual(resp['x-subject-token'], subject_token)
@ -46,7 +47,7 @@ class TokensV3TestJSON(base.BaseIdentityV3AdminTest):
self.assertEqual(token_details['user']['name'], u_name)
# Perform Delete Token
self.client.delete_token(subject_token)
self.assertRaises(lib_exc.NotFound, self.client.show_token,
self.assertRaises(lib_exc.NotFound, self.client.check_token_existence,
subject_token)
@decorators.idempotent_id('565fa210-1da1-4563-999b-f7b5b67cf112')

View File

@ -44,6 +44,13 @@ class IdentityClient(rest_client.RestClient):
self.expected_success(204, resp.status)
return rest_client.ResponseBody(resp, body)
def check_token_existence(self, resp_token):
"""Validates a token."""
headers = {'X-Subject-Token': resp_token}
resp, body = self.head("auth/tokens", headers=headers)
self.expected_success(200, resp.status)
return rest_client.ResponseBody(resp, body)
def list_auth_projects(self):
"""Get available project scopes."""
resp, body = self.get("auth/projects")

View File

@ -109,6 +109,14 @@ class TestIdentityClient(base.BaseServiceTest):
resp_token="cbc36478b0bd8e67e89",
status=204)
def test_check_token_existence(self):
self.check_service_client_function(
self.client.check_token_existence,
'tempest.lib.common.rest_client.RestClient.head',
{},
resp_token="cbc36478b0bd8e67e89",
status=200)
def test_list_auth_projects_with_str_body(self):
self._test_list_auth_projects()