diff options
author | Nicolas Helgeson <nh202b@att.com> | 2017-02-14 09:36:37 -0800 |
---|---|---|
committer | Nicolas Helgeson <nh202b@att.com> | 2017-03-23 16:15:37 +0000 |
commit | 8e2d403283f160b0dbc7d8cdbb42e7a432da0a38 (patch) | |
tree | 2214bb53e668ccfe5987842534c6714eef03bc1f /tempest/api | |
parent | 05efdd12657b20d6bc3419d8d40ec6f89d6a6064 (diff) | |
download | tempest-8e2d403283f160b0dbc7d8cdbb42e7a432da0a38.tar.gz |
Identity V3-ext Oauth1 Consumers Client
Adding a new client lib to handle the OAUTH consumers API testing
Included unit tests for the client lib, and
API tests for the OAUTH consumers API
Co-Authored-By: Nishant Kumar <nk613n@att.com>
Co-Authored-By: Avishek Dutta <ad620p@att.com>
Change-Id: I6d0884637cfe00a5313a5d019e1e062316f76d57
Closes-Bug: #1672810
Diffstat (limited to 'tempest/api')
-rw-r--r-- | tempest/api/identity/admin/v3/test_oauth_consumers.py | 91 | ||||
-rw-r--r-- | tempest/api/identity/base.py | 1 |
2 files changed, 92 insertions, 0 deletions
diff --git a/tempest/api/identity/admin/v3/test_oauth_consumers.py b/tempest/api/identity/admin/v3/test_oauth_consumers.py new file mode 100644 index 000000000..f06fb8f5f --- /dev/null +++ b/tempest/api/identity/admin/v3/test_oauth_consumers.py @@ -0,0 +1,91 @@ +# Copyright 2017 AT&T Corporation. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from tempest.api.identity import base +from tempest.common.utils import data_utils +from tempest.lib.common.utils import test_utils +from tempest.lib import decorators +from tempest.lib import exceptions as exceptions + + +class OAUTHConsumersV3Test(base.BaseIdentityV3AdminTest): + + def _create_consumer(self): + """Creates a consumer with a random description.""" + description = data_utils.rand_name('test_create_consumer') + consumer = self.oauth_consumers_client.create_consumer( + description)['consumer'] + # cleans up created consumers after tests + self.addCleanup(test_utils.call_and_ignore_notfound_exc, + self.oauth_consumers_client.delete_consumer, + consumer['id']) + return consumer + + @decorators.idempotent_id('c8307ea6-a86c-47fd-ae7b-5b3b2caca76d') + def test_create_and_show_consumer(self): + """Tests to make sure that a consumer with parameters is made""" + consumer = self._create_consumer() + # fetch created consumer from client + fetched_consumer = self.oauth_consumers_client.show_consumer( + consumer['id'])['consumer'] + # assert that the fetched consumer matches the created one and + # has all parameters + for key in ['description', 'id', 'links']: + self.assertEqual(consumer[key], fetched_consumer[key]) + + @decorators.idempotent_id('fdfa1b7f-2a31-4354-b2c7-f6ae20554f93') + def test_delete_consumer(self): + """Tests the delete function.""" + consumer = self._create_consumer() + # fetch consumer from client to confirm it exists + fetched_consumer = self.oauth_consumers_client.show_consumer( + consumer['id'])['consumer'] + self.assertEqual(consumer['id'], fetched_consumer['id']) + # delete existing consumer + self.oauth_consumers_client.delete_consumer(consumer['id']) + # check that consumer no longer exists + self.assertRaises(exceptions.NotFound, + self.oauth_consumers_client.show_consumer, + consumer['id']) + + @decorators.idempotent_id('080a9b1a-c009-47c0-9979-5305bf72e3dc') + def test_update_consumer(self): + """Tests the update functionality""" + # create a new consumer to update + consumer = self._create_consumer() + # create new description + new_description = data_utils.rand_name('test_update_consumer') + # update consumer + self.oauth_consumers_client.update_consumer(consumer['id'], + new_description) + # check that the same consumer now has the new description + updated_consumer = self.oauth_consumers_client.show_consumer( + consumer['id'])['consumer'] + self.assertEqual(new_description, updated_consumer['description']) + + @decorators.idempotent_id('09ca50de-78f2-4ffb-ac71-f2254036b2b8') + def test_list_consumers(self): + """Test for listing consumers""" + # create two consumers to populate list + new_consumer_one = self._create_consumer() + new_consumer_two = self._create_consumer() + # fetch the list of consumers + consumer_list = self.oauth_consumers_client \ + .list_consumers()['consumers'] + # add fetched consumer ids to a list + id_list = [consumer['id'] for consumer in consumer_list] + # check if created consumers are in the list + self.assertIn(new_consumer_one['id'], id_list) + self.assertIn(new_consumer_two['id'], id_list) diff --git a/tempest/api/identity/base.py b/tempest/api/identity/base.py index 9339d3c71..8317535c6 100644 --- a/tempest/api/identity/base.py +++ b/tempest/api/identity/base.py @@ -212,6 +212,7 @@ class BaseIdentityV3AdminTest(BaseIdentityV3Test): cls.groups_client = cls.os_adm.groups_client cls.projects_client = cls.os_adm.projects_client cls.role_assignments = cls.os_admin.role_assignments_client + cls.oauth_consumers_client = cls.os_adm.oauth_consumers_client if CONF.identity.admin_domain_scope: # NOTE(andreaf) When keystone policy requires it, the identity # admin clients for these tests shall use 'domain' scoped tokens. |