Skip to content

Commit

Permalink
[openvpn] Added explicit list_identifiers attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
nemesifier committed Jun 6, 2017
1 parent 5ddc201 commit dde3c9b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions netjsonconfig/backends/openvpn/openvpn.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class OpenVpn(BaseBackend):
schema = schema
converters = [converters.OpenVpn]
renderer = OpenVpnRenderer
list_identifiers = ['name']
VPN_REGEXP = re.compile('# openvpn config: ')

def _generate_contents(self, tar):
Expand Down
18 changes: 17 additions & 1 deletion tests/openvpn/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,14 @@ def test_client_mode(self):

_simple_conf = {
"openvpn": [{
"name": "test",
"ca": "ca.pem",
"cert": "cert.pem",
"dev": "tap0",
"dev_type": "tap",
"dh": "dh.pem",
"key": "key.pem",
"mode": "server",
"name": "test",
"proto": "udp",
"status": "",
"status_version": 1,
Expand Down Expand Up @@ -683,3 +683,19 @@ def test_resolv_retry_invalid(self):
def test_double_rendering(self):
o = OpenVpn(self._simple_conf)
self.assertEqual(o.render(), o.render())

def test_override(self):
template = {
"openvpn": [{
"name": "test",
"ca": "TEST",
"cert": "TEST",
"dev": "TEST",
"dev_type": "TEST",
"dh": "TEST",
"key": "TEST",
}]
}
o = OpenVpn(self._simple_conf, templates=[template])
# ensure dummy values in template have been overridden
self.assertDictEqual(o.config, self._simple_conf)

0 comments on commit dde3c9b

Please sign in to comment.