Filip Hubík | 8135405 | 2015-03-09 19:04:23 +0100 | [diff] [blame] | 1 | # Copyright 2015 OpenStack Foundation. |
| 2 | # Copyright 2015, Red Hat, Inc. |
| 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 | |
| 16 | from tempest.api.identity import base |
Saikiran | 692dcc1 | 2019-07-30 15:53:54 +0530 | [diff] [blame] | 17 | from tempest import config |
Ken'ichi Ohmichi | 44f0127 | 2017-01-27 18:44:14 -0800 | [diff] [blame] | 18 | from tempest.lib import decorators |
Filip Hubík | 8135405 | 2015-03-09 19:04:23 +0100 | [diff] [blame] | 19 | |
| 20 | |
Saikiran | 692dcc1 | 2019-07-30 15:53:54 +0530 | [diff] [blame] | 21 | CONF = config.CONF |
| 22 | |
| 23 | |
Filip Hubík | 8135405 | 2015-03-09 19:04:23 +0100 | [diff] [blame] | 24 | class TestApiDiscovery(base.BaseIdentityV3Test): |
zhufl | 8e3aacd | 2020-04-27 14:46:46 +0800 | [diff] [blame] | 25 | """Tests for identity API discovery features.""" |
Filip Hubík | 8135405 | 2015-03-09 19:04:23 +0100 | [diff] [blame] | 26 | |
Saikiran | 692dcc1 | 2019-07-30 15:53:54 +0530 | [diff] [blame] | 27 | @decorators.idempotent_id('79aec9ae-710f-4c54-a4fc-3aa25b4feac3') |
| 28 | def test_identity_v3_existence(self): |
zhufl | 8e3aacd | 2020-04-27 14:46:46 +0800 | [diff] [blame] | 29 | """Test that identity v3 version should exist""" |
Saikiran | 692dcc1 | 2019-07-30 15:53:54 +0530 | [diff] [blame] | 30 | versions = self.non_admin_versions_client.list_versions() |
| 31 | found = any( |
| 32 | "v3" in version.get('id') |
| 33 | for version in versions['versions']['values']) |
| 34 | self.assertEqual(CONF.identity_feature_enabled.api_v3, found) |
| 35 | |
Ken'ichi Ohmichi | da26b16 | 2017-03-03 15:53:46 -0800 | [diff] [blame] | 36 | @decorators.idempotent_id('721f480f-35b6-46c7-846e-047e6acea0dc') |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 37 | @decorators.attr(type='smoke') |
Ken'ichi Ohmichi | da26b16 | 2017-03-03 15:53:46 -0800 | [diff] [blame] | 38 | def test_list_api_versions(self): |
zhufl | 8e3aacd | 2020-04-27 14:46:46 +0800 | [diff] [blame] | 39 | """Test listing identity api versions |
| 40 | |
| 41 | NOTE: Actually this API doesn't depend on v3 API at all, because |
| 42 | the API operation is "GET /" without v3's endpoint. The reason of |
| 43 | this test path is just v3 API is CURRENT on Keystone side. |
| 44 | """ |
Ken'ichi Ohmichi | da26b16 | 2017-03-03 15:53:46 -0800 | [diff] [blame] | 45 | versions = self.non_admin_versions_client.list_versions() |
| 46 | expected_resources = ('id', 'links', 'media-types', 'status', |
| 47 | 'updated') |
| 48 | |
| 49 | for version in versions['versions']["values"]: |
| 50 | for res in expected_resources: |
| 51 | self.assertIn(res, version) |
| 52 | |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 53 | @decorators.attr(type='smoke') |
Ken'ichi Ohmichi | 44f0127 | 2017-01-27 18:44:14 -0800 | [diff] [blame] | 54 | @decorators.idempotent_id('b9232f5e-d9e5-4d97-b96c-28d3db4de1bd') |
Filip Hubík | 8135405 | 2015-03-09 19:04:23 +0100 | [diff] [blame] | 55 | def test_api_version_resources(self): |
zhufl | 8e3aacd | 2020-04-27 14:46:46 +0800 | [diff] [blame] | 56 | """Test showing identity v3 api version resources""" |
Ken'ichi Ohmichi | 402b875 | 2015-11-09 10:47:16 +0000 | [diff] [blame] | 57 | descr = self.non_admin_client.show_api_description()['version'] |
Filip Hubík | 8135405 | 2015-03-09 19:04:23 +0100 | [diff] [blame] | 58 | expected_resources = ('id', 'links', 'media-types', 'status', |
| 59 | 'updated') |
| 60 | |
| 61 | keys = descr.keys() |
| 62 | for res in expected_resources: |
| 63 | self.assertIn(res, keys) |
| 64 | |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 65 | @decorators.attr(type='smoke') |
Ken'ichi Ohmichi | 44f0127 | 2017-01-27 18:44:14 -0800 | [diff] [blame] | 66 | @decorators.idempotent_id('657c1970-4722-4189-8831-7325f3bc4265') |
Filip Hubík | 8135405 | 2015-03-09 19:04:23 +0100 | [diff] [blame] | 67 | def test_api_media_types(self): |
zhufl | 8e3aacd | 2020-04-27 14:46:46 +0800 | [diff] [blame] | 68 | """Test showing identity v3 api version media type""" |
Ken'ichi Ohmichi | 402b875 | 2015-11-09 10:47:16 +0000 | [diff] [blame] | 69 | descr = self.non_admin_client.show_api_description()['version'] |
Filip Hubík | 8135405 | 2015-03-09 19:04:23 +0100 | [diff] [blame] | 70 | # Get MIME type bases and descriptions |
| 71 | media_types = [(media_type['base'], media_type['type']) for |
| 72 | media_type in descr['media-types']] |
| 73 | # These are supported for API version 2 |
| 74 | supported_types = [('application/json', |
| 75 | 'application/vnd.openstack.identity-v3+json')] |
| 76 | |
| 77 | # Check if supported types exist in response body |
| 78 | for s_type in supported_types: |
| 79 | self.assertIn(s_type, media_types) |
| 80 | |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 81 | @decorators.attr(type='smoke') |
Ken'ichi Ohmichi | 44f0127 | 2017-01-27 18:44:14 -0800 | [diff] [blame] | 82 | @decorators.idempotent_id('8879a470-abfb-47bb-bb8d-5a7fd279ad1e') |
Filip Hubík | 8135405 | 2015-03-09 19:04:23 +0100 | [diff] [blame] | 83 | def test_api_version_statuses(self): |
zhufl | 8e3aacd | 2020-04-27 14:46:46 +0800 | [diff] [blame] | 84 | """Test showing identity v3 api version status""" |
Ken'ichi Ohmichi | 402b875 | 2015-11-09 10:47:16 +0000 | [diff] [blame] | 85 | descr = self.non_admin_client.show_api_description()['version'] |
Filip Hubík | 8135405 | 2015-03-09 19:04:23 +0100 | [diff] [blame] | 86 | status = descr['status'].lower() |
| 87 | supported_statuses = ['current', 'stable', 'experimental', |
| 88 | 'supported', 'deprecated'] |
| 89 | |
| 90 | self.assertIn(status, supported_statuses) |