Ken'ichi Ohmichi | 2b6012b | 2015-09-03 01:56:19 +0000 | [diff] [blame] | 1 | # 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 | |
| 15 | from tempest.api.compute import base |
| 16 | from tempest import test |
| 17 | |
| 18 | |
| 19 | class TestVersions(base.BaseComputeTest): |
| 20 | |
| 21 | @test.idempotent_id('6c0a0990-43b6-4529-9b61-5fd8daf7c55c') |
| 22 | def test_list_api_versions(self): |
Ken'ichi Ohmichi | 5085f06 | 2015-09-04 02:12:42 +0000 | [diff] [blame] | 23 | """Test that a get of the unversioned url returns the choices doc. |
| 24 | |
| 25 | A key feature in OpenStack services is the idea that you can |
| 26 | GET / on the service and get a list of the versioned endpoints |
| 27 | that you can access. This comes back as a status 300 |
| 28 | request. It's important that this is available to API |
| 29 | consumers to discover the API they can use. |
| 30 | |
| 31 | """ |
Ken'ichi Ohmichi | 2b6012b | 2015-09-03 01:56:19 +0000 | [diff] [blame] | 32 | result = self.versions_client.list_versions() |
Ken'ichi Ohmichi | 5085f06 | 2015-09-04 02:12:42 +0000 | [diff] [blame] | 33 | versions = result['versions'] |
| 34 | # NOTE(sdague): at a later point we may want to loosen this |
| 35 | # up, but for now this should be true of all Novas deployed. |
| 36 | self.assertEqual(versions[0]['id'], 'v2.0', |
| 37 | "The first listed version should be v2.0") |
| 38 | |
| 39 | @test.idempotent_id('b953a29e-929c-4a8e-81be-ec3a7e03cb76') |
| 40 | def test_get_version_details(self): |
| 41 | """Test individual version endpoints info works. |
| 42 | |
| 43 | In addition to the GET / version request, there is also a |
| 44 | version info document stored at the top of the versioned |
| 45 | endpoints. This provides access to details about that |
| 46 | endpoint, including min / max version if that implements |
| 47 | microversions. |
| 48 | |
| 49 | This test starts with the version list, iterates all the |
| 50 | returned endpoints, and fetches them. This will also ensure |
| 51 | that all the version links are followable constructs which |
| 52 | will help detect configuration issues when SSL termination |
| 53 | isn't done completely for a site. |
| 54 | |
| 55 | """ |
| 56 | result = self.versions_client.list_versions() |
| 57 | versions = result['versions'] |
| 58 | |
| 59 | # iterate through all the versions that are returned and |
| 60 | # attempt to get their version documents. |
| 61 | for version in versions: |
| 62 | links = [x for x in version['links'] if x['rel'] == 'self'] |
| 63 | self.assertEqual( |
| 64 | len(links), 1, |
| 65 | "There should only be 1 self link in %s" % version) |
| 66 | link = links[0] |
| 67 | # this is schema validated |
| 68 | result = self.versions_client.get_version_by_url(link['href']) |
| 69 | # ensure the new self link matches the old one |
| 70 | newlinks = [x for x in result['version']['links'] |
| 71 | if x['rel'] == 'self'] |
| 72 | self.assertEqual(links, newlinks) |