blob: 6141553858d358ea664702a332ccef626e37daee [file] [log] [blame]
Ken'ichi Ohmichi2b6012b2015-09-03 01:56:19 +00001# Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15from tempest.api.compute import base
Ken'ichi Ohmichi6c92edf2017-01-27 17:32:10 -080016from tempest.lib import decorators
Ken'ichi Ohmichi2b6012b2015-09-03 01:56:19 +000017
18
Ken'ichi Ohmichi02a8ccd2015-11-05 06:05:29 +000019class TestVersions(base.BaseV2ComputeTest):
Ken'ichi Ohmichi2b6012b2015-09-03 01:56:19 +000020
Ken'ichi Ohmichi6c92edf2017-01-27 17:32:10 -080021 @decorators.idempotent_id('6c0a0990-43b6-4529-9b61-5fd8daf7c55c')
Jordan Pittier3b46d272017-04-12 16:17:28 +020022 @decorators.attr(type='smoke')
Ken'ichi Ohmichi2b6012b2015-09-03 01:56:19 +000023 def test_list_api_versions(self):
Ken'ichi Ohmichi5085f062015-09-04 02:12:42 +000024 """Test that a get of the unversioned url returns the choices doc.
25
26 A key feature in OpenStack services is the idea that you can
27 GET / on the service and get a list of the versioned endpoints
28 that you can access. This comes back as a status 300
29 request. It's important that this is available to API
30 consumers to discover the API they can use.
31
32 """
Ken'ichi Ohmichi2b6012b2015-09-03 01:56:19 +000033 result = self.versions_client.list_versions()
Ken'ichi Ohmichi5085f062015-09-04 02:12:42 +000034 versions = result['versions']
35 # NOTE(sdague): at a later point we may want to loosen this
36 # up, but for now this should be true of all Novas deployed.
37 self.assertEqual(versions[0]['id'], 'v2.0',
38 "The first listed version should be v2.0")
39
Ken'ichi Ohmichi6c92edf2017-01-27 17:32:10 -080040 @decorators.idempotent_id('b953a29e-929c-4a8e-81be-ec3a7e03cb76')
Jordan Pittier3b46d272017-04-12 16:17:28 +020041 @decorators.attr(type='smoke')
Ken'ichi Ohmichi5085f062015-09-04 02:12:42 +000042 def test_get_version_details(self):
43 """Test individual version endpoints info works.
44
45 In addition to the GET / version request, there is also a
46 version info document stored at the top of the versioned
47 endpoints. This provides access to details about that
48 endpoint, including min / max version if that implements
49 microversions.
50
51 This test starts with the version list, iterates all the
52 returned endpoints, and fetches them. This will also ensure
53 that all the version links are followable constructs which
54 will help detect configuration issues when SSL termination
55 isn't done completely for a site.
56
57 """
58 result = self.versions_client.list_versions()
59 versions = result['versions']
60
61 # iterate through all the versions that are returned and
62 # attempt to get their version documents.
63 for version in versions:
64 links = [x for x in version['links'] if x['rel'] == 'self']
65 self.assertEqual(
66 len(links), 1,
67 "There should only be 1 self link in %s" % version)
68 link = links[0]
69 # this is schema validated
70 result = self.versions_client.get_version_by_url(link['href'])
71 # ensure the new self link matches the old one
72 newlinks = [x for x in result['version']['links']
73 if x['rel'] == 'self']
74 self.assertEqual(links, newlinks)