blob: 2662e9cc115176e57f4162fc660f92ffbb4369df [file] [log] [blame]
Nayna Pateld0b02ae2013-09-04 10:09:08 +00001# Copyright 2013 OpenStack, Foundation
2# All Rights Reserved.
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
17from tempest.api.network import base
Ken'ichi Ohmichi53b9a632017-01-27 18:04:39 -080018from tempest.lib import decorators
armando-migliaccio328d45d2013-12-13 13:46:20 -080019from tempest import test
Nayna Pateld0b02ae2013-09-04 10:09:08 +000020
21
22class ExtensionsTestJSON(base.BaseNetworkTest):
Ken'ichi Ohmichie03bea92015-11-19 07:45:58 +000023 """Tests the following operations in the Neutron API:
Nayna Pateld0b02ae2013-09-04 10:09:08 +000024
25 List all available extensions
26
Tianbiao Qi9f1e8d42016-09-29 11:08:21 +080027 v2.0 of the Neutron API is assumed. It is also assumed that api-extensions
28 option is defined in the [network-feature-enabled] section of
29 etc/tempest.conf.
Nayna Pateld0b02ae2013-09-04 10:09:08 +000030 """
31
armando-migliaccio328d45d2013-12-13 13:46:20 -080032 @test.attr(type='smoke')
Ken'ichi Ohmichi53b9a632017-01-27 18:04:39 -080033 @decorators.idempotent_id('ef28c7e6-e646-4979-9d67-deb207bc5564')
Nayna Pateld0b02ae2013-09-04 10:09:08 +000034 def test_list_show_extensions(self):
Sean Dagueed6e5862016-04-04 10:49:13 -040035 # List available extensions for the project
Nayna Pateld0b02ae2013-09-04 10:09:08 +000036 expected_alias = ['security-group', 'l3_agent_scheduler',
37 'ext-gw-mode', 'binding', 'quotas',
38 'agent', 'dhcp_agent_scheduler', 'provider',
39 'router', 'extraroute', 'external-net',
Takeaki Matsumotoabeb07f2015-08-11 20:52:53 +090040 'allowed-address-pairs', 'extra_dhcp_opt',
Sean Dague42b9e872015-09-02 06:31:54 -040041 'metering', 'dvr']
Yoshihiro Kaneko05670262014-01-18 19:22:44 +090042 expected_alias = [ext for ext in expected_alias if
43 test.is_extension_enabled(ext, 'network')]
Nayna Pateld0b02ae2013-09-04 10:09:08 +000044 actual_alias = list()
Ken'ichi Ohmichi52bb8122016-01-26 01:43:06 +000045 extensions = self.network_extensions_client.list_extensions()
Nayna Pateld0b02ae2013-09-04 10:09:08 +000046 list_extensions = extensions['extensions']
47 # Show and verify the details of the available extensions
48 for ext in list_extensions:
49 ext_name = ext['name']
50 ext_alias = ext['alias']
51 actual_alias.append(ext['alias'])
Ken'ichi Ohmichi52bb8122016-01-26 01:43:06 +000052 ext_details = self.network_extensions_client.show_extension(
53 ext_alias)
Nayna Pateld0b02ae2013-09-04 10:09:08 +000054 ext_details = ext_details['extension']
55
56 self.assertIsNotNone(ext_details)
57 self.assertIn('updated', ext_details.keys())
58 self.assertIn('name', ext_details.keys())
59 self.assertIn('description', ext_details.keys())
Nayna Pateld0b02ae2013-09-04 10:09:08 +000060 self.assertIn('links', ext_details.keys())
61 self.assertIn('alias', ext_details.keys())
62 self.assertEqual(ext_details['name'], ext_name)
63 self.assertEqual(ext_details['alias'], ext_alias)
64 self.assertEqual(ext_details, ext)
65 # Verify if expected extensions are present in the actual list
armando-migliaccio328d45d2013-12-13 13:46:20 -080066 # of extensions returned, but only for those that have been
67 # enabled via configuration
Nayna Pateld0b02ae2013-09-04 10:09:08 +000068 for e in expected_alias:
armando-migliaccio328d45d2013-12-13 13:46:20 -080069 if test.is_extension_enabled(e, 'network'):
70 self.assertIn(e, actual_alias)