blob: f56688f157112c2823ab8342cb7eb5c8b310a0fa [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
armando-migliaccio328d45d2013-12-13 13:46:20 -080018from tempest import test
Nayna Pateld0b02ae2013-09-04 10:09:08 +000019
20
21class ExtensionsTestJSON(base.BaseNetworkTest):
Nayna Pateld0b02ae2013-09-04 10:09:08 +000022
23 """
24 Tests the following operations in the Neutron API using the REST client for
25 Neutron:
26
27 List all available extensions
28
29 v2.0 of the Neutron API is assumed. It is also assumed that the following
30 options are defined in the [network] section of etc/tempest.conf:
31
32 """
33
armando-migliaccio328d45d2013-12-13 13:46:20 -080034 @test.attr(type='smoke')
Chris Hoge7579c1a2015-02-26 14:12:15 -080035 @test.idempotent_id('ef28c7e6-e646-4979-9d67-deb207bc5564')
Nayna Pateld0b02ae2013-09-04 10:09:08 +000036 def test_list_show_extensions(self):
37 # List available extensions for the tenant
38 expected_alias = ['security-group', 'l3_agent_scheduler',
39 'ext-gw-mode', 'binding', 'quotas',
40 'agent', 'dhcp_agent_scheduler', 'provider',
41 'router', 'extraroute', 'external-net',
Takeaki Matsumotoabeb07f2015-08-11 20:52:53 +090042 'allowed-address-pairs', 'extra_dhcp_opt',
43 'metering', 'dvr', 'service-type']
Yoshihiro Kaneko05670262014-01-18 19:22:44 +090044 expected_alias = [ext for ext in expected_alias if
45 test.is_extension_enabled(ext, 'network')]
Nayna Pateld0b02ae2013-09-04 10:09:08 +000046 actual_alias = list()
David Kranz34e88122014-12-11 15:24:05 -050047 extensions = self.client.list_extensions()
Nayna Pateld0b02ae2013-09-04 10:09:08 +000048 list_extensions = extensions['extensions']
49 # Show and verify the details of the available extensions
50 for ext in list_extensions:
51 ext_name = ext['name']
52 ext_alias = ext['alias']
53 actual_alias.append(ext['alias'])
David Kranz34e88122014-12-11 15:24:05 -050054 ext_details = self.client.show_extension(ext_alias)
Nayna Pateld0b02ae2013-09-04 10:09:08 +000055 ext_details = ext_details['extension']
56
57 self.assertIsNotNone(ext_details)
58 self.assertIn('updated', ext_details.keys())
59 self.assertIn('name', ext_details.keys())
60 self.assertIn('description', ext_details.keys())
Nayna Pateld0b02ae2013-09-04 10:09:08 +000061 self.assertIn('links', ext_details.keys())
62 self.assertIn('alias', ext_details.keys())
63 self.assertEqual(ext_details['name'], ext_name)
64 self.assertEqual(ext_details['alias'], ext_alias)
65 self.assertEqual(ext_details, ext)
66 # Verify if expected extensions are present in the actual list
armando-migliaccio328d45d2013-12-13 13:46:20 -080067 # of extensions returned, but only for those that have been
68 # enabled via configuration
Nayna Pateld0b02ae2013-09-04 10:09:08 +000069 for e in expected_alias:
armando-migliaccio328d45d2013-12-13 13:46:20 -080070 if test.is_extension_enabled(e, 'network'):
71 self.assertIn(e, actual_alias)