diff --git a/releasenotes/notes/identity_client-635275d43abbb807.yaml b/releasenotes/notes/identity_client-635275d43abbb807.yaml new file mode 100644 index 0000000000..6f984b74e8 --- /dev/null +++ b/releasenotes/notes/identity_client-635275d43abbb807.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + Enhances the v3 identity client with the ``check_token_existence`` + endpoint, allowing users to check the existence of tokens diff --git a/tempest/api/identity/admin/v3/test_tokens.py b/tempest/api/identity/admin/v3/test_tokens.py index 8c5e63ba2a..0eb7f4f027 100644 --- a/tempest/api/identity/admin/v3/test_tokens.py +++ b/tempest/api/identity/admin/v3/test_tokens.py @@ -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') diff --git a/tempest/lib/services/identity/v3/identity_client.py b/tempest/lib/services/identity/v3/identity_client.py index 755c14b2cf..2512a3edc2 100644 --- a/tempest/lib/services/identity/v3/identity_client.py +++ b/tempest/lib/services/identity/v3/identity_client.py @@ -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") diff --git a/tempest/tests/lib/services/identity/v3/test_identity_client.py b/tempest/tests/lib/services/identity/v3/test_identity_client.py index e435fe294b..6572947fe7 100644 --- a/tempest/tests/lib/services/identity/v3/test_identity_client.py +++ b/tempest/tests/lib/services/identity/v3/test_identity_client.py @@ -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()