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 |
Ken'ichi Ohmichi | 44f0127 | 2017-01-27 18:44:14 -0800 | [diff] [blame] | 17 | from tempest.lib import decorators |
Filip Hubík | 8135405 | 2015-03-09 19:04:23 +0100 | [diff] [blame] | 18 | from tempest import test |
| 19 | |
| 20 | |
| 21 | class TestApiDiscovery(base.BaseIdentityV3Test): |
| 22 | """Tests for API discovery features.""" |
| 23 | |
Ken'ichi Ohmichi | da26b16 | 2017-03-03 15:53:46 -0800 | [diff] [blame] | 24 | @decorators.idempotent_id('721f480f-35b6-46c7-846e-047e6acea0dc') |
| 25 | @test.attr(type='smoke') |
| 26 | def test_list_api_versions(self): |
| 27 | # NOTE: Actually this API doesn't depend on v3 API at all, because |
| 28 | # the API operation is "GET /" without v3's endpoint. The reason of |
| 29 | # this test path is just v3 API is CURRENT on Keystone side. |
| 30 | versions = self.non_admin_versions_client.list_versions() |
| 31 | expected_resources = ('id', 'links', 'media-types', 'status', |
| 32 | 'updated') |
| 33 | |
| 34 | for version in versions['versions']["values"]: |
| 35 | for res in expected_resources: |
| 36 | self.assertIn(res, version) |
| 37 | |
Filip Hubík | 8135405 | 2015-03-09 19:04:23 +0100 | [diff] [blame] | 38 | @test.attr(type='smoke') |
Ken'ichi Ohmichi | 44f0127 | 2017-01-27 18:44:14 -0800 | [diff] [blame] | 39 | @decorators.idempotent_id('b9232f5e-d9e5-4d97-b96c-28d3db4de1bd') |
Filip Hubík | 8135405 | 2015-03-09 19:04:23 +0100 | [diff] [blame] | 40 | def test_api_version_resources(self): |
Ken'ichi Ohmichi | 402b875 | 2015-11-09 10:47:16 +0000 | [diff] [blame] | 41 | descr = self.non_admin_client.show_api_description()['version'] |
Filip Hubík | 8135405 | 2015-03-09 19:04:23 +0100 | [diff] [blame] | 42 | expected_resources = ('id', 'links', 'media-types', 'status', |
| 43 | 'updated') |
| 44 | |
| 45 | keys = descr.keys() |
| 46 | for res in expected_resources: |
| 47 | self.assertIn(res, keys) |
| 48 | |
| 49 | @test.attr(type='smoke') |
Ken'ichi Ohmichi | 44f0127 | 2017-01-27 18:44:14 -0800 | [diff] [blame] | 50 | @decorators.idempotent_id('657c1970-4722-4189-8831-7325f3bc4265') |
Filip Hubík | 8135405 | 2015-03-09 19:04:23 +0100 | [diff] [blame] | 51 | def test_api_media_types(self): |
Ken'ichi Ohmichi | 402b875 | 2015-11-09 10:47:16 +0000 | [diff] [blame] | 52 | descr = self.non_admin_client.show_api_description()['version'] |
Filip Hubík | 8135405 | 2015-03-09 19:04:23 +0100 | [diff] [blame] | 53 | # Get MIME type bases and descriptions |
| 54 | media_types = [(media_type['base'], media_type['type']) for |
| 55 | media_type in descr['media-types']] |
| 56 | # These are supported for API version 2 |
| 57 | supported_types = [('application/json', |
| 58 | 'application/vnd.openstack.identity-v3+json')] |
| 59 | |
| 60 | # Check if supported types exist in response body |
| 61 | for s_type in supported_types: |
| 62 | self.assertIn(s_type, media_types) |
| 63 | |
| 64 | @test.attr(type='smoke') |
Ken'ichi Ohmichi | 44f0127 | 2017-01-27 18:44:14 -0800 | [diff] [blame] | 65 | @decorators.idempotent_id('8879a470-abfb-47bb-bb8d-5a7fd279ad1e') |
Filip Hubík | 8135405 | 2015-03-09 19:04:23 +0100 | [diff] [blame] | 66 | def test_api_version_statuses(self): |
Ken'ichi Ohmichi | 402b875 | 2015-11-09 10:47:16 +0000 | [diff] [blame] | 67 | descr = self.non_admin_client.show_api_description()['version'] |
Filip Hubík | 8135405 | 2015-03-09 19:04:23 +0100 | [diff] [blame] | 68 | status = descr['status'].lower() |
| 69 | supported_statuses = ['current', 'stable', 'experimental', |
| 70 | 'supported', 'deprecated'] |
| 71 | |
| 72 | self.assertIn(status, supported_statuses) |