blob: 02caef5363ada84f05ae73be315342026a26762f [file] [log] [blame]
Filip Hubík81354052015-03-09 19:04:23 +01001# 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
16from tempest.api.identity import base
Ken'ichi Ohmichieeabdd22017-01-27 17:46:00 -080017from tempest.lib import decorators
Filip Hubík81354052015-03-09 19:04:23 +010018from tempest import test
19
20
21class TestApiDiscovery(base.BaseIdentityV2Test):
22 """Tests for API discovery features."""
23
24 @test.attr(type='smoke')
Ken'ichi Ohmichieeabdd22017-01-27 17:46:00 -080025 @decorators.idempotent_id('ea889a68-a15f-4166-bfb1-c12456eae853')
Filip Hubík81354052015-03-09 19:04:23 +010026 def test_api_version_resources(self):
Ken'ichi Ohmichi402b8752015-11-09 10:47:16 +000027 descr = self.non_admin_client.show_api_description()['version']
Filip Hubík81354052015-03-09 19:04:23 +010028 expected_resources = ('id', 'links', 'media-types', 'status',
29 'updated')
30
31 keys = descr.keys()
32 for res in expected_resources:
33 self.assertIn(res, keys)
34
35 @test.attr(type='smoke')
Ken'ichi Ohmichieeabdd22017-01-27 17:46:00 -080036 @decorators.idempotent_id('007a0be0-78fe-4fdb-bbee-e9216cc17bb2')
Filip Hubík81354052015-03-09 19:04:23 +010037 def test_api_media_types(self):
Ken'ichi Ohmichi402b8752015-11-09 10:47:16 +000038 descr = self.non_admin_client.show_api_description()['version']
Filip Hubík81354052015-03-09 19:04:23 +010039 # Get MIME type bases and descriptions
40 media_types = [(media_type['base'], media_type['type']) for
41 media_type in descr['media-types']]
42 # These are supported for API version 2
43 supported_types = [('application/json',
44 'application/vnd.openstack.identity-v2.0+json')]
45
46 # Check if supported types exist in response body
47 for s_type in supported_types:
48 self.assertIn(s_type, media_types)
49
50 @test.attr(type='smoke')
Ken'ichi Ohmichieeabdd22017-01-27 17:46:00 -080051 @decorators.idempotent_id('77fd6be0-8801-48e6-b9bf-38cdd2f253ec')
Filip Hubík81354052015-03-09 19:04:23 +010052 def test_api_version_statuses(self):
Ken'ichi Ohmichi402b8752015-11-09 10:47:16 +000053 descr = self.non_admin_client.show_api_description()['version']
Filip Hubík81354052015-03-09 19:04:23 +010054 status = descr['status'].lower()
55 supported_statuses = ['current', 'stable', 'experimental',
56 'supported', 'deprecated']
57
58 self.assertIn(status, supported_statuses)