1# Licensed under the Apache License, Version 2.0 (the "License"); you may
2# not use this file except in compliance with the License. You may obtain
3# a copy of the License at
4#
5#      http://www.apache.org/licenses/LICENSE-2.0
6#
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10# License for the specific language governing permissions and limitations
11# under the License.
12
13from openstack.network.v2 import ipsec_site_connection
14from openstack.tests.unit import base
15
16
17IDENTIFIER = 'IDENTIFIER'
18EXAMPLE = {
19    "admin_state_up": True,
20    "auth_mode": "1",
21    "ikepolicy_id": "2",
22    "vpnservice_id": "3",
23    "local_ep_group_id": "4",
24    "peer_address": "5",
25    "route_mode": "6",
26    "ipsecpolicy_id": "7",
27    "peer_id": "8",
28    "psk": "9",
29    "description": "10",
30    "initiator": "11",
31    "peer_cidrs": ['1', '2'],
32    "name": "12",
33    "tenant_id": "13",
34    "interval": 5,
35    "mtu": 5,
36    "peer_ep_group_id": "14",
37    "dpd": {'a': 5},
38    "timeout": 16,
39    "action": "17",
40    "local_id": "18"
41}
42
43
44class TestIPSecSiteConnection(base.TestCase):
45
46    def test_basic(self):
47        sot = ipsec_site_connection.IPSecSiteConnection()
48        self.assertEqual('ipsec_site_connection', sot.resource_key)
49        self.assertEqual('ipsec_site_connections', sot.resources_key)
50        self.assertEqual('/vpn/ipsec-site-connections', sot.base_path)
51        self.assertTrue(sot.allow_create)
52        self.assertTrue(sot.allow_fetch)
53        self.assertTrue(sot.allow_commit)
54        self.assertTrue(sot.allow_delete)
55        self.assertTrue(sot.allow_list)
56
57    def test_make_it(self):
58        sot = ipsec_site_connection.IPSecSiteConnection(**EXAMPLE)
59        self.assertTrue(sot.is_admin_state_up)
60        self.assertEqual(EXAMPLE['auth_mode'], sot.auth_mode)
61        self.assertEqual(EXAMPLE['ikepolicy_id'], sot.ikepolicy_id)
62        self.assertEqual(EXAMPLE['vpnservice_id'], sot.vpnservice_id)
63        self.assertEqual(EXAMPLE['local_ep_group_id'], sot.local_ep_group_id)
64        self.assertEqual(EXAMPLE['peer_address'], sot.peer_address)
65        self.assertEqual(EXAMPLE['route_mode'], sot.route_mode)
66        self.assertEqual(EXAMPLE['ipsecpolicy_id'], sot.ipsecpolicy_id)
67        self.assertEqual(EXAMPLE['peer_id'], sot.peer_id)
68        self.assertEqual(EXAMPLE['psk'], sot.psk)
69        self.assertEqual(EXAMPLE['description'], sot.description)
70        self.assertEqual(EXAMPLE['initiator'], sot.initiator)
71        self.assertEqual(EXAMPLE['peer_cidrs'], sot.peer_cidrs)
72        self.assertEqual(EXAMPLE['name'], sot.name)
73        self.assertEqual(EXAMPLE['tenant_id'], sot.project_id)
74        self.assertEqual(EXAMPLE['interval'], sot.interval)
75        self.assertEqual(EXAMPLE['mtu'], sot.mtu)
76        self.assertEqual(EXAMPLE['peer_ep_group_id'], sot.peer_ep_group_id)
77        self.assertEqual(EXAMPLE['dpd'], sot.dpd)
78        self.assertEqual(EXAMPLE['timeout'], sot.timeout)
79        self.assertEqual(EXAMPLE['action'], sot.action)
80        self.assertEqual(EXAMPLE['local_id'], sot.local_id)
81