Skip to content

Commit

Permalink
[Fix] Multiple templates defining the same additional file generate c…
Browse files Browse the repository at this point in the history
…onflicts #197

Fixes #197
  • Loading branch information
codesankalp committed Mar 14, 2022
1 parent 109b3f4 commit b1d71a6
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion netjsonconfig/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@
"files": {
"type": "array",
"title": "Files",
"uniqueItems": True,
"uniqueItems": False,
"additionalItems": True,
"propertyOrder": 20,
"items": {
Expand Down
39 changes: 39 additions & 0 deletions tests/openvpn/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -882,3 +882,42 @@ def test_tls_auth_key_present(self):
)
client = OpenVpn(client_config)
self.assertEqual(client.render(), self._openvpn_client_tls_auth_render)

def test_ca_same_file_path_for_same_device(self):
conf = {
"ca": "/etc/x509/ca.pem",
"cert": "cert.pem",
"dev": "tap0",
"dev_type": "tap",
"dh": "dh.pem",
"key": "key.pem",
"mode": "server",
"name": "test-1",
"proto": "udp",
"tls_server": True,
}
ca_file = {"path": "/etc/x509/ca.pem", "mode": "0644", "contents": "testing!"}
template1 = {
"openvpn": [{**conf}],
"files": [ca_file],
}
template2 = {
"openvpn": [
{
**conf,
"name": "test-2",
"cert": "cert2.pem",
}
],
"files": [ca_file],
}
client = OpenVpn(
{
"openvpn": [conf],
},
templates=[template1, template2],
)
try:
client.render()
except ValidationError as err:
self.fail("ValidationError raised: {}".format(err))

0 comments on commit b1d71a6

Please sign in to comment.