blob: a177d657ceca39bdf88c2f693321e4fc20cb95a9 [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']
47 actual_alias = list()
48 resp, extensions = self.client.list_extensions()
49 self.assertEqual('200', resp['status'])
50 list_extensions = extensions['extensions']
51 # Show and verify the details of the available extensions
52 for ext in list_extensions:
53 ext_name = ext['name']
54 ext_alias = ext['alias']
55 actual_alias.append(ext['alias'])
Eugene Nikanorov909ded12013-12-15 17:45:37 +040056 resp, ext_details = self.client.show_extension(ext_alias)
Nayna Pateld0b02ae2013-09-04 10:09:08 +000057 self.assertEqual('200', resp['status'])
58 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'