blob: 529f8e9028502ecb8aee71398cae62e00c0a8314 [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
36 def setUpClass(cls):
37 super(ExtensionsTestJSON, cls).setUpClass()
38
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()
50 resp, extensions = self.client.list_extensions()
51 self.assertEqual('200', resp['status'])
52 list_extensions = extensions['extensions']
53 # Show and verify the details of the available extensions
54 for ext in list_extensions:
55 ext_name = ext['name']
56 ext_alias = ext['alias']
57 actual_alias.append(ext['alias'])
Eugene Nikanorov909ded12013-12-15 17:45:37 +040058 resp, ext_details = self.client.show_extension(ext_alias)
Nayna Pateld0b02ae2013-09-04 10:09:08 +000059 self.assertEqual('200', resp['status'])
60 ext_details = ext_details['extension']
61
62 self.assertIsNotNone(ext_details)
63 self.assertIn('updated', ext_details.keys())
64 self.assertIn('name', ext_details.keys())
65 self.assertIn('description', ext_details.keys())
66 self.assertIn('namespace', ext_details.keys())
67 self.assertIn('links', ext_details.keys())
68 self.assertIn('alias', ext_details.keys())
69 self.assertEqual(ext_details['name'], ext_name)
70 self.assertEqual(ext_details['alias'], ext_alias)
71 self.assertEqual(ext_details, ext)
72 # Verify if expected extensions are present in the actual list
armando-migliaccio328d45d2013-12-13 13:46:20 -080073 # of extensions returned, but only for those that have been
74 # enabled via configuration
Nayna Pateld0b02ae2013-09-04 10:09:08 +000075 for e in expected_alias:
armando-migliaccio328d45d2013-12-13 13:46:20 -080076 if test.is_extension_enabled(e, 'network'):
77 self.assertIn(e, actual_alias)
Nayna Pateld0b02ae2013-09-04 10:09:08 +000078
79
80class ExtensionsTestXML(ExtensionsTestJSON):
81 _interface = 'xml'