blob: 9cbc7ac1af5e393bc33e62c936b3f6332c0d935f [file] [log] [blame]
Anju Tiwari860097d2013-10-17 11:10:39 +05301# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
3# Copyright 2013 OpenStack Foundation
4# All Rights Reserved.
5#
6# Licensed under the Apache License, Version 2.0 (the "License"); you may
7# not use this file except in compliance with the License. You may obtain
8# a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15# License for the specific language governing permissions and limitations
16# under the License.
17
18from tempest.api.network import base
Masayuki Igawa259c1132013-10-31 17:48:44 +090019from tempest.common.utils import data_utils
Anju Tiwari860097d2013-10-17 11:10:39 +053020from tempest.test import attr
21
22
23class VPNaaSJSON(base.BaseNetworkTest):
24 _interface = 'json'
25
26 """
27 Tests the following operations in the Neutron API using the REST client for
28 Neutron:
29
30 List VPN Services
31 Show VPN Services
32 Create VPN Services
33 Update VPN Services
34 Delete VPN Services
35 """
36
37 @classmethod
38 def setUpClass(cls):
39 super(VPNaaSJSON, cls).setUpClass()
40 cls.network = cls.create_network()
41 cls.subnet = cls.create_subnet(cls.network)
Masayuki Igawa259c1132013-10-31 17:48:44 +090042 cls.router = cls.create_router(data_utils.rand_name("router-"))
Anju Tiwari860097d2013-10-17 11:10:39 +053043 cls.create_router_interface(cls.router['id'], cls.subnet['id'])
44 cls.vpnservice = cls.create_vpnservice(cls.subnet['id'],
45 cls.router['id'])
46
47 @attr(type='smoke')
48 def test_list_vpn_services(self):
49 # Verify the VPN service exists in the list of all VPN services
50 resp, body = self.client.list_vpn_services()
51 self.assertEqual('200', resp['status'])
52 vpnservices = body['vpnservices']
53 self.assertIn(self.vpnservice['id'], [v['id'] for v in vpnservices])
54
55 @attr(type='smoke')
56 def test_create_update_delete_vpn_service(self):
57 # Creates a VPN service
Masayuki Igawa259c1132013-10-31 17:48:44 +090058 name = data_utils.rand_name('vpn-service-')
Anju Tiwari860097d2013-10-17 11:10:39 +053059 resp, body = self.client.create_vpn_service(self.subnet['id'],
60 self.router['id'],
61 name=name,
62 admin_state_up=True)
63 self.assertEqual('201', resp['status'])
64 vpnservice = body['vpnservice']
65 # Assert if created vpnservices are not found in vpnservices list
66 resp, body = self.client.list_vpn_services()
67 vpn_services = [vs['id'] for vs in body['vpnservices']]
68 self.assertIsNotNone(vpnservice['id'])
69 self.assertIn(vpnservice['id'], vpn_services)
70
71 # TODO(raies): implement logic to update vpnservice
72 # VPNaaS client function to update is implemented.
73 # But precondition is that current state of vpnservice
74 # should be "ACTIVE" not "PENDING*"
75
76 # Verification of vpn service delete
77 resp, body = self.client.delete_vpn_service(vpnservice['id'])
78 self.assertEqual('204', resp['status'])
79 # Asserting if vpn service is found in the list after deletion
80 resp, body = self.client.list_vpn_services()
81 vpn_services = [vs['id'] for vs in body['vpnservices']]
82 self.assertNotIn(vpnservice['id'], vpn_services)
83
84 @attr(type='smoke')
85 def test_show_vpn_service(self):
86 # Verifies the details of a vpn service
87 resp, body = self.client.show_vpn_service(self.vpnservice['id'])
88 self.assertEqual('200', resp['status'])
89 vpnservice = body['vpnservice']
90 self.assertEqual(self.vpnservice['id'], vpnservice['id'])
91 self.assertEqual(self.vpnservice['name'], vpnservice['name'])
92 self.assertEqual(self.vpnservice['description'],
93 vpnservice['description'])
94 self.assertEqual(self.vpnservice['router_id'], vpnservice['router_id'])
95 self.assertEqual(self.vpnservice['subnet_id'], vpnservice['subnet_id'])
96 self.assertEqual(self.vpnservice['tenant_id'], vpnservice['tenant_id'])