blob: 715136c1d80110841970a49c14449e2b64f3682a [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):
22 _interface = 'json'
23
24 """
25 Tests the following operations in the Neutron API using the REST client for
26 Neutron:
27
28 List all available extensions
29
30 v2.0 of the Neutron API is assumed. It is also assumed that the following
31 options are defined in the [network] section of etc/tempest.conf:
32
33 """
34
35 @classmethod
Andrea Frittolida4a2452014-09-15 13:12:08 +010036 def resource_setup(cls):
37 super(ExtensionsTestJSON, cls).resource_setup()
Nayna Pateld0b02ae2013-09-04 10:09:08 +000038
armando-migliaccio328d45d2013-12-13 13:46:20 -080039 @test.attr(type='smoke')
Nayna Pateld0b02ae2013-09-04 10:09:08 +000040 def test_list_show_extensions(self):
41 # List available extensions for the tenant
42 expected_alias = ['security-group', 'l3_agent_scheduler',
43 'ext-gw-mode', 'binding', 'quotas',
44 'agent', 'dhcp_agent_scheduler', 'provider',
45 'router', 'extraroute', 'external-net',
46 'allowed-address-pairs', 'extra_dhcp_opt']
Yoshihiro Kaneko05670262014-01-18 19:22:44 +090047 expected_alias = [ext for ext in expected_alias if
48 test.is_extension_enabled(ext, 'network')]
Nayna Pateld0b02ae2013-09-04 10:09:08 +000049 actual_alias = list()
Rohan Kanadeeeb21642014-08-14 12:00:26 +020050 _, extensions = self.client.list_extensions()
Nayna Pateld0b02ae2013-09-04 10:09:08 +000051 list_extensions = extensions['extensions']
52 # Show and verify the details of the available extensions
53 for ext in list_extensions:
54 ext_name = ext['name']
55 ext_alias = ext['alias']
56 actual_alias.append(ext['alias'])
Rohan Kanadeeeb21642014-08-14 12:00:26 +020057 _, ext_details = self.client.show_extension(ext_alias)
Nayna Pateld0b02ae2013-09-04 10:09:08 +000058 ext_details = ext_details['extension']
59
60 self.assertIsNotNone(ext_details)
61 self.assertIn('updated', ext_details.keys())
62 self.assertIn('name', ext_details.keys())
63 self.assertIn('description', ext_details.keys())
64 self.assertIn('namespace', ext_details.keys())
65 self.assertIn('links', ext_details.keys())
66 self.assertIn('alias', ext_details.keys())
67 self.assertEqual(ext_details['name'], ext_name)
68 self.assertEqual(ext_details['alias'], ext_alias)
69 self.assertEqual(ext_details, ext)
70 # Verify if expected extensions are present in the actual list
armando-migliaccio328d45d2013-12-13 13:46:20 -080071 # of extensions returned, but only for those that have been
72 # enabled via configuration
Nayna Pateld0b02ae2013-09-04 10:09:08 +000073 for e in expected_alias:
armando-migliaccio328d45d2013-12-13 13:46:20 -080074 if test.is_extension_enabled(e, 'network'):
75 self.assertIn(e, actual_alias)
Nayna Pateld0b02ae2013-09-04 10:09:08 +000076
77
78class ExtensionsTestXML(ExtensionsTestJSON):
79 _interface = 'xml'