From afbc3a386bc360320f5f92250640da069777b821 Mon Sep 17 00:00:00 2001 From: Federico Capoano Date: Fri, 2 Sep 2016 15:35:58 +0200 Subject: [PATCH] [openwisp] Fixed openvpn integration (partially backward incompatible) --- netjsonconfig/backends/openwisp/openwisp.py | 4 +- tests/openwisp/test_backend.py | 50 +++++++++++---------- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/netjsonconfig/backends/openwisp/openwisp.py b/netjsonconfig/backends/openwisp/openwisp.py index 87d1ddf1b..0da9323ed 100644 --- a/netjsonconfig/backends/openwisp/openwisp.py +++ b/netjsonconfig/backends/openwisp/openwisp.py @@ -9,8 +9,7 @@ class OpenWisp(OpenWrt): """ OpenWisp 1.x Backend """ schema = schema - openwisp_env = Environment(loader=PackageLoader('netjsonconfig.backends.openwisp', - 'templates'), + openwisp_env = Environment(loader=PackageLoader('netjsonconfig.backends.openwisp', 'templates'), trim_blocks=True) def validate(self): @@ -48,7 +47,6 @@ def _get_install_context(self): if vpn.get('dev_type') != 'tap': continue tap = vpn.copy() - tap['name'] = tap['config_value'] l2vpn.append(tap) # bridge list bridges = [] diff --git a/tests/openwisp/test_backend.py b/tests/openwisp/test_backend.py index eb0323301..81e9f4e96 100644 --- a/tests/openwisp/test_backend.py +++ b/tests/openwisp/test_backend.py @@ -64,34 +64,38 @@ class TestBackend(unittest.TestCase, _TabsMixin): ], "openvpn": [ { - "config_name": "openvpn", - "config_value": "2693", - "enabled": "1", - "client": "1", + "ca": "/tmp/owispmanager/openvpn/x509/ca_1_service.pem", + "cert": "/tmp/owispmanager/openvpn/x509/l2vpn_client_2693.pem", + "cipher": "AES-128-CBC", + "comp_lzo": "yes", "dev": "tap0", "dev_type": "tap", - "proto": "tcp-client", - "remote": "vpn.openwisp.org 12128", - "nobind": "1", + "down": "/tmp/owispmanager/openvpn/vpn_2693_script_down.sh", + "enabled": True, "keepalive": "5 40", - "ns_cert_type": "server", - "resolv_retry": "infinite", - "comp_lzo": "yes", - "tls_client": "1", - "ca": "/tmp/owispmanager/openvpn/x509/ca_1_service.pem", "key": "/tmp/owispmanager/openvpn/x509/l2vpn_client_2693.pem", - "cert": "/tmp/owispmanager/openvpn/x509/l2vpn_client_2693.pem", + "log": "/tmp/openvpn_2693.log", + "mode": "client", + "mute": 10, + "mute_replay_warnings": True, + "name": "2693", + "nobind": True, + "ns_cert_type": "server", + "persist_tun": True, + "proto": "tcp-client", + "remote": [ + { + "host": "vpn.openwisp.org", + "port": 12128 + } + ], + "resolv_retry": True, + "script_security": 1, + "tls_client": True, "up": "/tmp/owispmanager/openvpn/vpn_2693_script_up.sh", - "down": "/tmp/owispmanager/openvpn/vpn_2693_script_down.sh", - "cipher": "AES-128-CBC", - "script_security": "3", - "up_delay": "1", - "up_restart": "1", - "persist_tun": "1", - "mute_replay_warnings": "1", - "verb": "1", - "mute": "10", - "log": "/tmp/openvpn_2693.log" + "up_delay": 1, + "up_restart": True, + "verb": 1 } ], "tc_options": [