rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 1 | # Copyright 2013 OpenStack Foundation |
| 2 | # All Rights Reserved. |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 5 | # not use this file except in compliance with the License. You may obtain |
| 6 | # a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 | # License for the specific language governing permissions and limitations |
| 14 | # under the License. |
| 15 | |
Sean Dague | 1937d09 | 2013-05-17 16:36:38 -0400 | [diff] [blame] | 16 | from tempest.api.identity import base |
Fei Long Wang | d39431f | 2015-05-14 11:30:48 +1200 | [diff] [blame] | 17 | from tempest.common.utils import data_utils |
Ken'ichi Ohmichi | eeabdd2 | 2017-01-27 17:46:00 -0800 | [diff] [blame] | 18 | from tempest.lib import decorators |
Masayuki Igawa | df15468 | 2014-03-19 18:32:00 +0900 | [diff] [blame] | 19 | from tempest import test |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 20 | |
| 21 | |
Matthew Treinish | db2c597 | 2014-01-31 22:18:59 +0000 | [diff] [blame] | 22 | class EndPointsTestJSON(base.BaseIdentityV3AdminTest): |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 23 | |
| 24 | @classmethod |
Rohan Kanade | b645e17 | 2015-02-05 17:38:59 +0530 | [diff] [blame] | 25 | def setup_clients(cls): |
| 26 | super(EndPointsTestJSON, cls).setup_clients() |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 27 | cls.client = cls.endpoints_client |
Rohan Kanade | b645e17 | 2015-02-05 17:38:59 +0530 | [diff] [blame] | 28 | |
| 29 | @classmethod |
| 30 | def resource_setup(cls): |
| 31 | super(EndPointsTestJSON, cls).resource_setup() |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 32 | cls.service_ids = list() |
Ken'ichi Ohmichi | 9650847 | 2015-03-23 01:43:42 +0000 | [diff] [blame] | 33 | s_name = data_utils.rand_name('service') |
| 34 | s_type = data_utils.rand_name('type') |
| 35 | s_description = data_utils.rand_name('description') |
zhufl | 95a3281 | 2017-03-01 17:52:21 +0800 | [diff] [blame^] | 36 | service_data = ( |
Yaroslav Lobankov | 69d9056 | 2015-12-18 12:06:40 +0300 | [diff] [blame] | 37 | cls.services_client.create_service(name=s_name, type=s_type, |
| 38 | description=s_description)) |
zhufl | 95a3281 | 2017-03-01 17:52:21 +0800 | [diff] [blame^] | 39 | cls.service_id = service_data['service']['id'] |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 40 | cls.service_ids.append(cls.service_id) |
Attila Fazekas | f7f34f9 | 2013-08-01 17:01:44 +0200 | [diff] [blame] | 41 | # Create endpoints so as to use for LIST and GET test cases |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 42 | cls.setup_endpoints = list() |
zhufl | 8e9a073 | 2017-01-26 16:15:21 +0800 | [diff] [blame] | 43 | for _ in range(2): |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 44 | region = data_utils.rand_name('region') |
Dolph Mathews | 064e965 | 2014-07-11 10:54:38 -0500 | [diff] [blame] | 45 | url = data_utils.rand_url() |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 46 | interface = 'public' |
Yaroslav Lobankov | 2b459ec | 2015-11-09 15:01:48 +0300 | [diff] [blame] | 47 | endpoint = cls.client.create_endpoint(service_id=cls.service_id, |
| 48 | interface=interface, |
| 49 | url=url, region=region, |
| 50 | enabled=True)['endpoint'] |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 51 | cls.setup_endpoints.append(endpoint) |
| 52 | |
| 53 | @classmethod |
Andrea Frittoli | 7688e74 | 2014-09-15 12:38:22 +0100 | [diff] [blame] | 54 | def resource_cleanup(cls): |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 55 | for e in cls.setup_endpoints: |
| 56 | cls.client.delete_endpoint(e['id']) |
| 57 | for s in cls.service_ids: |
Yaroslav Lobankov | 69d9056 | 2015-12-18 12:06:40 +0300 | [diff] [blame] | 58 | cls.services_client.delete_service(s) |
Andrea Frittoli | 7688e74 | 2014-09-15 12:38:22 +0100 | [diff] [blame] | 59 | super(EndPointsTestJSON, cls).resource_cleanup() |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 60 | |
Ken'ichi Ohmichi | eeabdd2 | 2017-01-27 17:46:00 -0800 | [diff] [blame] | 61 | @decorators.idempotent_id('c19ecf90-240e-4e23-9966-21cee3f6a618') |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 62 | def test_list_endpoints(self): |
| 63 | # Get a list of endpoints |
John Warren | 47f504b | 2015-08-11 20:25:05 +0000 | [diff] [blame] | 64 | fetched_endpoints = self.client.list_endpoints()['endpoints'] |
Chang Bo Guo | f099f80 | 2013-09-13 19:01:46 -0700 | [diff] [blame] | 65 | # Asserting LIST endpoints |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 66 | missing_endpoints =\ |
| 67 | [e for e in self.setup_endpoints if e not in fetched_endpoints] |
| 68 | self.assertEqual(0, len(missing_endpoints), |
| 69 | "Failed to find endpoint %s in fetched list" % |
| 70 | ', '.join(str(e) for e in missing_endpoints)) |
| 71 | |
Ken'ichi Ohmichi | eeabdd2 | 2017-01-27 17:46:00 -0800 | [diff] [blame] | 72 | @decorators.idempotent_id('0e2446d2-c1fd-461b-a729-b9e73e3e3b37') |
apetrov | 5ae389f | 2016-01-21 16:16:13 +0100 | [diff] [blame] | 73 | def test_create_list_show_delete_endpoint(self): |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 74 | region = data_utils.rand_name('region') |
Dolph Mathews | 064e965 | 2014-07-11 10:54:38 -0500 | [diff] [blame] | 75 | url = data_utils.rand_url() |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 76 | interface = 'public' |
Yaroslav Lobankov | 2b459ec | 2015-11-09 15:01:48 +0300 | [diff] [blame] | 77 | endpoint = self.client.create_endpoint(service_id=self.service_id, |
| 78 | interface=interface, |
| 79 | url=url, region=region, |
| 80 | enabled=True)['endpoint'] |
apetrov | 5ae389f | 2016-01-21 16:16:13 +0100 | [diff] [blame] | 81 | |
Ghanshyam | 8aa8dcb | 2016-02-10 15:11:01 +0900 | [diff] [blame] | 82 | self.setup_endpoints.append(endpoint) |
Giulio Fidente | 92f7719 | 2013-08-26 17:13:28 +0200 | [diff] [blame] | 83 | # Asserting Create Endpoint response body |
Giulio Fidente | 92f7719 | 2013-08-26 17:13:28 +0200 | [diff] [blame] | 84 | self.assertIn('id', endpoint) |
| 85 | self.assertEqual(region, endpoint['region']) |
| 86 | self.assertEqual(url, endpoint['url']) |
apetrov | 5ae389f | 2016-01-21 16:16:13 +0100 | [diff] [blame] | 87 | |
Giulio Fidente | 92f7719 | 2013-08-26 17:13:28 +0200 | [diff] [blame] | 88 | # Checking if created endpoint is present in the list of endpoints |
John Warren | 47f504b | 2015-08-11 20:25:05 +0000 | [diff] [blame] | 89 | fetched_endpoints = self.client.list_endpoints()['endpoints'] |
Giulio Fidente | 92f7719 | 2013-08-26 17:13:28 +0200 | [diff] [blame] | 90 | fetched_endpoints_id = [e['id'] for e in fetched_endpoints] |
| 91 | self.assertIn(endpoint['id'], fetched_endpoints_id) |
apetrov | 5ae389f | 2016-01-21 16:16:13 +0100 | [diff] [blame] | 92 | |
| 93 | # Show endpoint |
| 94 | fetched_endpoint = ( |
| 95 | self.client.show_endpoint(endpoint['id'])['endpoint']) |
| 96 | # Asserting if the attributes of endpoint are the same |
| 97 | self.assertEqual(self.service_id, fetched_endpoint['service_id']) |
| 98 | self.assertEqual(interface, fetched_endpoint['interface']) |
| 99 | self.assertEqual(url, fetched_endpoint['url']) |
| 100 | self.assertEqual(region, fetched_endpoint['region']) |
| 101 | self.assertEqual(True, fetched_endpoint['enabled']) |
| 102 | |
Giulio Fidente | 92f7719 | 2013-08-26 17:13:28 +0200 | [diff] [blame] | 103 | # Deleting the endpoint created in this method |
ghanshyam | a201637 | 2014-10-24 11:15:01 +0900 | [diff] [blame] | 104 | self.client.delete_endpoint(endpoint['id']) |
Ghanshyam | 8aa8dcb | 2016-02-10 15:11:01 +0900 | [diff] [blame] | 105 | self.setup_endpoints.remove(endpoint) |
apetrov | 5ae389f | 2016-01-21 16:16:13 +0100 | [diff] [blame] | 106 | |
Giulio Fidente | 92f7719 | 2013-08-26 17:13:28 +0200 | [diff] [blame] | 107 | # Checking whether endpoint is deleted successfully |
John Warren | 47f504b | 2015-08-11 20:25:05 +0000 | [diff] [blame] | 108 | fetched_endpoints = self.client.list_endpoints()['endpoints'] |
Giulio Fidente | 92f7719 | 2013-08-26 17:13:28 +0200 | [diff] [blame] | 109 | fetched_endpoints_id = [e['id'] for e in fetched_endpoints] |
| 110 | self.assertNotIn(endpoint['id'], fetched_endpoints_id) |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 111 | |
Masayuki Igawa | df15468 | 2014-03-19 18:32:00 +0900 | [diff] [blame] | 112 | @test.attr(type='smoke') |
Ken'ichi Ohmichi | eeabdd2 | 2017-01-27 17:46:00 -0800 | [diff] [blame] | 113 | @decorators.idempotent_id('37e8f15e-ee7c-4657-a1e7-f6b61e375eff') |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 114 | def test_update_endpoint(self): |
Attila Fazekas | f7f34f9 | 2013-08-01 17:01:44 +0200 | [diff] [blame] | 115 | # Creating an endpoint so as to check update endpoint |
| 116 | # with new values |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 117 | region1 = data_utils.rand_name('region') |
Dolph Mathews | 064e965 | 2014-07-11 10:54:38 -0500 | [diff] [blame] | 118 | url1 = data_utils.rand_url() |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 119 | interface1 = 'public' |
Yaroslav Lobankov | 2b459ec | 2015-11-09 15:01:48 +0300 | [diff] [blame] | 120 | endpoint_for_update = ( |
| 121 | self.client.create_endpoint(service_id=self.service_id, |
| 122 | interface=interface1, |
| 123 | url=url1, region=region1, |
| 124 | enabled=True)['endpoint']) |
Brant Knudson | 3a9bdf9 | 2014-02-27 17:09:50 -0600 | [diff] [blame] | 125 | self.addCleanup(self.client.delete_endpoint, endpoint_for_update['id']) |
Attila Fazekas | f7f34f9 | 2013-08-01 17:01:44 +0200 | [diff] [blame] | 126 | # Creating service so as update endpoint with new service ID |
Ken'ichi Ohmichi | 9650847 | 2015-03-23 01:43:42 +0000 | [diff] [blame] | 127 | s_name = data_utils.rand_name('service') |
| 128 | s_type = data_utils.rand_name('type') |
| 129 | s_description = data_utils.rand_name('description') |
Yaroslav Lobankov | 61db2d9 | 2015-11-11 16:51:23 +0300 | [diff] [blame] | 130 | service2 = ( |
Yaroslav Lobankov | 69d9056 | 2015-12-18 12:06:40 +0300 | [diff] [blame] | 131 | self.services_client.create_service(name=s_name, type=s_type, |
| 132 | description=s_description)) |
John Warren | f96750d | 2015-08-13 13:44:59 +0000 | [diff] [blame] | 133 | service2 = service2['service'] |
Pranav Salunke | 9b3029c | 2014-05-25 00:01:05 +0530 | [diff] [blame] | 134 | self.service_ids.append(service2['id']) |
Attila Fazekas | f7f34f9 | 2013-08-01 17:01:44 +0200 | [diff] [blame] | 135 | # Updating endpoint with new values |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 136 | region2 = data_utils.rand_name('region') |
Dolph Mathews | 064e965 | 2014-07-11 10:54:38 -0500 | [diff] [blame] | 137 | url2 = data_utils.rand_url() |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 138 | interface2 = 'internal' |
Yaroslav Lobankov | 2b459ec | 2015-11-09 15:01:48 +0300 | [diff] [blame] | 139 | endpoint = self.client.update_endpoint(endpoint_for_update['id'], |
| 140 | service_id=service2['id'], |
| 141 | interface=interface2, |
| 142 | url=url2, region=region2, |
| 143 | enabled=False)['endpoint'] |
Attila Fazekas | f7f34f9 | 2013-08-01 17:01:44 +0200 | [diff] [blame] | 144 | # Asserting if the attributes of endpoint are updated |
Pranav Salunke | 9b3029c | 2014-05-25 00:01:05 +0530 | [diff] [blame] | 145 | self.assertEqual(service2['id'], endpoint['service_id']) |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 146 | self.assertEqual(interface2, endpoint['interface']) |
| 147 | self.assertEqual(url2, endpoint['url']) |
| 148 | self.assertEqual(region2, endpoint['region']) |
Ken'ichi Ohmichi | 73cb70b | 2015-04-17 02:31:12 +0000 | [diff] [blame] | 149 | self.assertEqual(False, endpoint['enabled']) |