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 |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 17 | from tempest.common.utils import data_utils |
Masayuki Igawa | df15468 | 2014-03-19 18:32:00 +0900 | [diff] [blame] | 18 | from tempest import test |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 19 | |
| 20 | |
Matthew Treinish | db2c597 | 2014-01-31 22:18:59 +0000 | [diff] [blame] | 21 | class EndPointsTestJSON(base.BaseIdentityV3AdminTest): |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 22 | |
| 23 | @classmethod |
Rohan Kanade | b645e17 | 2015-02-05 17:38:59 +0530 | [diff] [blame] | 24 | def setup_clients(cls): |
| 25 | super(EndPointsTestJSON, cls).setup_clients() |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 26 | cls.identity_client = cls.client |
| 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() |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [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-') |
David Kranz | d8ccb79 | 2014-12-29 11:32:05 -0500 | [diff] [blame] | 36 | cls.service_data =\ |
Matthew Treinish | db2c597 | 2014-01-31 22:18:59 +0000 | [diff] [blame] | 37 | cls.service_client.create_service(s_name, s_type, |
| 38 | description=s_description) |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 39 | cls.service_id = cls.service_data['id'] |
| 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() |
| 43 | for i 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' |
David Kranz | d8ccb79 | 2014-12-29 11:32:05 -0500 | [diff] [blame] | 47 | endpoint = cls.client.create_endpoint( |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 48 | cls.service_id, interface, url, region=region, enabled=True) |
| 49 | cls.setup_endpoints.append(endpoint) |
| 50 | |
| 51 | @classmethod |
Andrea Frittoli | 7688e74 | 2014-09-15 12:38:22 +0100 | [diff] [blame] | 52 | def resource_cleanup(cls): |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 53 | for e in cls.setup_endpoints: |
| 54 | cls.client.delete_endpoint(e['id']) |
| 55 | for s in cls.service_ids: |
Matthew Treinish | db2c597 | 2014-01-31 22:18:59 +0000 | [diff] [blame] | 56 | cls.service_client.delete_service(s) |
Andrea Frittoli | 7688e74 | 2014-09-15 12:38:22 +0100 | [diff] [blame] | 57 | super(EndPointsTestJSON, cls).resource_cleanup() |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 58 | |
Masayuki Igawa | df15468 | 2014-03-19 18:32:00 +0900 | [diff] [blame] | 59 | @test.attr(type='gate') |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 60 | def test_list_endpoints(self): |
| 61 | # Get a list of endpoints |
David Kranz | d8ccb79 | 2014-12-29 11:32:05 -0500 | [diff] [blame] | 62 | fetched_endpoints = self.client.list_endpoints() |
Chang Bo Guo | f099f80 | 2013-09-13 19:01:46 -0700 | [diff] [blame] | 63 | # Asserting LIST endpoints |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 64 | missing_endpoints =\ |
| 65 | [e for e in self.setup_endpoints if e not in fetched_endpoints] |
| 66 | self.assertEqual(0, len(missing_endpoints), |
| 67 | "Failed to find endpoint %s in fetched list" % |
| 68 | ', '.join(str(e) for e in missing_endpoints)) |
| 69 | |
Masayuki Igawa | df15468 | 2014-03-19 18:32:00 +0900 | [diff] [blame] | 70 | @test.attr(type='gate') |
Giulio Fidente | 92f7719 | 2013-08-26 17:13:28 +0200 | [diff] [blame] | 71 | def test_create_list_delete_endpoint(self): |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 72 | region = data_utils.rand_name('region') |
Dolph Mathews | 064e965 | 2014-07-11 10:54:38 -0500 | [diff] [blame] | 73 | url = data_utils.rand_url() |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 74 | interface = 'public' |
David Kranz | d8ccb79 | 2014-12-29 11:32:05 -0500 | [diff] [blame] | 75 | endpoint =\ |
Giulio Fidente | 92f7719 | 2013-08-26 17:13:28 +0200 | [diff] [blame] | 76 | self.client.create_endpoint(self.service_id, interface, url, |
| 77 | region=region, enabled=True) |
| 78 | # Asserting Create Endpoint response body |
Giulio Fidente | 92f7719 | 2013-08-26 17:13:28 +0200 | [diff] [blame] | 79 | self.assertIn('id', endpoint) |
| 80 | self.assertEqual(region, endpoint['region']) |
| 81 | self.assertEqual(url, endpoint['url']) |
| 82 | # Checking if created endpoint is present in the list of endpoints |
David Kranz | d8ccb79 | 2014-12-29 11:32:05 -0500 | [diff] [blame] | 83 | fetched_endpoints = self.client.list_endpoints() |
Giulio Fidente | 92f7719 | 2013-08-26 17:13:28 +0200 | [diff] [blame] | 84 | fetched_endpoints_id = [e['id'] for e in fetched_endpoints] |
| 85 | self.assertIn(endpoint['id'], fetched_endpoints_id) |
| 86 | # Deleting the endpoint created in this method |
ghanshyam | a201637 | 2014-10-24 11:15:01 +0900 | [diff] [blame] | 87 | self.client.delete_endpoint(endpoint['id']) |
Giulio Fidente | 92f7719 | 2013-08-26 17:13:28 +0200 | [diff] [blame] | 88 | # Checking whether endpoint is deleted successfully |
David Kranz | d8ccb79 | 2014-12-29 11:32:05 -0500 | [diff] [blame] | 89 | fetched_endpoints = self.client.list_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.assertNotIn(endpoint['id'], fetched_endpoints_id) |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 92 | |
Masayuki Igawa | df15468 | 2014-03-19 18:32:00 +0900 | [diff] [blame] | 93 | @test.attr(type='smoke') |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 94 | def test_update_endpoint(self): |
Attila Fazekas | f7f34f9 | 2013-08-01 17:01:44 +0200 | [diff] [blame] | 95 | # Creating an endpoint so as to check update endpoint |
| 96 | # with new values |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 97 | region1 = data_utils.rand_name('region') |
Dolph Mathews | 064e965 | 2014-07-11 10:54:38 -0500 | [diff] [blame] | 98 | url1 = data_utils.rand_url() |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 99 | interface1 = 'public' |
David Kranz | d8ccb79 | 2014-12-29 11:32:05 -0500 | [diff] [blame] | 100 | endpoint_for_update =\ |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 101 | self.client.create_endpoint(self.service_id, interface1, |
| 102 | url1, region=region1, |
| 103 | enabled=True) |
Brant Knudson | 3a9bdf9 | 2014-02-27 17:09:50 -0600 | [diff] [blame] | 104 | self.addCleanup(self.client.delete_endpoint, endpoint_for_update['id']) |
Attila Fazekas | f7f34f9 | 2013-08-01 17:01:44 +0200 | [diff] [blame] | 105 | # Creating service so as update endpoint with new service ID |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 106 | s_name = data_utils.rand_name('service-') |
| 107 | s_type = data_utils.rand_name('type--') |
| 108 | s_description = data_utils.rand_name('description-') |
David Kranz | d8ccb79 | 2014-12-29 11:32:05 -0500 | [diff] [blame] | 109 | service2 =\ |
Matthew Treinish | db2c597 | 2014-01-31 22:18:59 +0000 | [diff] [blame] | 110 | self.service_client.create_service(s_name, s_type, |
| 111 | description=s_description) |
Pranav Salunke | 9b3029c | 2014-05-25 00:01:05 +0530 | [diff] [blame] | 112 | self.service_ids.append(service2['id']) |
Attila Fazekas | f7f34f9 | 2013-08-01 17:01:44 +0200 | [diff] [blame] | 113 | # Updating endpoint with new values |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 114 | region2 = data_utils.rand_name('region') |
Dolph Mathews | 064e965 | 2014-07-11 10:54:38 -0500 | [diff] [blame] | 115 | url2 = data_utils.rand_url() |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 116 | interface2 = 'internal' |
David Kranz | d8ccb79 | 2014-12-29 11:32:05 -0500 | [diff] [blame] | 117 | endpoint = \ |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 118 | self.client.update_endpoint(endpoint_for_update['id'], |
Pranav Salunke | 9b3029c | 2014-05-25 00:01:05 +0530 | [diff] [blame] | 119 | service_id=service2['id'], |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 120 | interface=interface2, url=url2, |
| 121 | region=region2, enabled=False) |
Attila Fazekas | f7f34f9 | 2013-08-01 17:01:44 +0200 | [diff] [blame] | 122 | # Asserting if the attributes of endpoint are updated |
Pranav Salunke | 9b3029c | 2014-05-25 00:01:05 +0530 | [diff] [blame] | 123 | self.assertEqual(service2['id'], endpoint['service_id']) |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 124 | self.assertEqual(interface2, endpoint['interface']) |
| 125 | self.assertEqual(url2, endpoint['url']) |
| 126 | self.assertEqual(region2, endpoint['region']) |
Brant Knudson | 3340299 | 2014-02-27 13:31:37 -0600 | [diff] [blame] | 127 | self.assertEqual('false', str(endpoint['enabled']).lower()) |