Skip to content
Permalink
Browse files
[openwrt] Renamed enabled to disabled in OpenVPN secion
In order to be consistent with the rest of the codebase,
the "enabled" attribute in the OpenVPN section of the
OpenWrt backend has been renamed to "disabled" and defaults
to False.
  • Loading branch information
nemesisdesign committed Jan 17, 2017
1 parent 88ef58c commit 7a152a344333665bbc9217011418ae39e8a1af81
@@ -2002,7 +2002,7 @@ The ``OpenWrt`` backend adds a few properties to the OpenVPN schema, see below.
+--------------------------+---------+--------------+-------------------------------------------------------------+
| key name | type | default | allowed values |
+==========================+=========+==============+=============================================================+
| ``enabled`` | boolean | ``True`` | |
| ``disabled`` | boolean | ``False`` | |
+--------------------------+---------+--------------+-------------------------------------------------------------+
OpenVPN example
@@ -2020,7 +2020,7 @@ The following *configuration dictionary*:
"dev": "tap0",
"dev_type": "tap",
"dh": "dh.pem",
"enabled": True,
"disabled": False,
"key": "key.pem",
"mode": "server",
"name": "test-vpn-server",
@@ -496,6 +496,10 @@ class OpenVpnRenderer(BaseOpenWrtRenderer, BaseOpenVpnRenderer):
"""
def _transform_vpn(self, vpn):
config = super(OpenVpnRenderer, self)._transform_vpn(vpn)
if 'enabled' not in config:
if 'disabled' in config:
config['enabled'] = not config['disabled']
del config['disabled']
# TODO: keep 'enabled' check until 0.6 and then drop it
elif 'disabled' not in config and 'enabled' not in config:
config['enabled'] = True
return config
@@ -465,11 +465,11 @@
"definitions": {
"tunnel": {
"properties": {
"enabled": {
"title": "enabled",
"description": "uncheck this to disable this VPN without deleting its configuration",
"disabled": {
"title": "disabled",
"description": "disable this VPN without deleting its configuration",
"type": "boolean",
"default": True,
"default": False,
"format": "checkbox",
"propertyOrder": 1
}
@@ -28,6 +28,7 @@ def test_server_mode(self):
"down": "",
"duplicate_cn": True,
"engine": "rsax",
# TODO: in 0.6.0 change this to "disabled": False
"enabled": True,
"fast_io": True,
"fragment": 0,
@@ -111,6 +112,7 @@ def test_client_mode(self):
"dev": "tun0",
"dev_type": "tun",
"down": "/home/user/down-command.sh",
# TODO: in 0.6.0 change this to "disabled": False
"enabled": True,
"engine": "",
"fast_io": False,
@@ -206,6 +208,7 @@ def test_no_status_file(self):
"dev": "tap0",
"dev_type": "tap",
"dh": "dh.pem",
# TODO: in 0.6.0 change this to "disabled": False
"enabled": True,
"key": "key.pem",
"mode": "server",
@@ -240,6 +243,7 @@ def test_additional_properties(self):
"dev": "tap0",
"dev_type": "tap",
"dh": "dh.pem",
# TODO: in 0.6.0 change this to "disabled": False
"enabled": True,
"key": "key.pem",
"mode": "server",
@@ -313,6 +317,7 @@ def test_server_bridge(self):
"dev": "tap0",
"dev_type": "tap",
"dh": "dh.pem",
# TODO: in 0.6.0 change this to "disabled": False
"enabled": True,
"key": "key.pem",
"mode": "server",
@@ -347,6 +352,7 @@ def test_server_bridge_proxy(self):
"dev": "tap0",
"dev_type": "tap",
"dh": "dh.pem",
# TODO: in 0.6.0 change this to "disabled": False
"enabled": True,
"key": "key.pem",
"mode": "server",
@@ -381,6 +387,7 @@ def test_server_bridge_routed(self):
"dev": "tap0",
"dev_type": "tap",
"dh": "dh.pem",
# TODO: in 0.6.0 change this to "disabled": False
"enabled": True,
"key": "key.pem",
"mode": "server",
@@ -404,5 +411,57 @@ def test_server_bridge_routed(self):
option proto 'udp'
option server '10.8.0.0 255.255.0.0'
option tls_server '1'
""")
self.assertEqual(c.render(), expected)

def test_disabled(self):
c = OpenWrt({
"openvpn": [{
"ca": "ca.pem",
"cert": "cert.pem",
"dev": "tap0",
"dev_type": "tap",
"dh": "dh.pem",
"disabled": True,
"key": "key.pem",
"mode": "server",
"name": "test-properties",
"proto": "udp",
"tls_server": True
}]
})
self.assertIn("option enabled '0'", c.render())

def test_disabled_and_enabled(self):
# disabled wins over enabled since 0.5.3
c = OpenWrt({
"openvpn": [{
"ca": "ca.pem",
"cert": "cert.pem",
"dev": "tap0",
"dev_type": "tap",
"dh": "dh.pem",
"disabled": True,
"enabled": True,
"key": "key.pem",
"mode": "server",
"name": "test-properties",
"proto": "udp",
"tls_server": True
}]
})
expected = self._tabs("""package openvpn
config openvpn 'test_properties'
option ca 'ca.pem'
option cert 'cert.pem'
option dev 'tap0'
option dev_type 'tap'
option dh 'dh.pem'
option enabled '0'
option key 'key.pem'
option mode 'server'
option proto 'udp'
option tls_server '1'
""")
self.assertEqual(c.render(), expected)

0 comments on commit 7a152a3

Please sign in to comment.