Skip to content

Commit

Permalink
[fix] File path shouldn't be allowed to be empty #166
Browse files Browse the repository at this point in the history
Fixes #166
  • Loading branch information
codesankalp committed Mar 10, 2022
1 parent eecbba4 commit 109b3f4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions netjsonconfig/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,7 @@
"type": "string",
"description": "filesystem path",
"propertyOrder": 1,
"minLength": 2,
},
"mode": {
"type": "string",
Expand Down
9 changes: 8 additions & 1 deletion tests/openvpn/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from copy import deepcopy

from netjsonconfig import OpenVpn
from netjsonconfig.exceptions import ParseError
from netjsonconfig.exceptions import ParseError, ValidationError


class TestParser(unittest.TestCase):
Expand Down Expand Up @@ -159,3 +159,10 @@ def test_parse_tar_file(self):
OpenVpn(native=open('/tmp/test.tar.gz'))
os.remove('/tmp/test.tar.gz')
self.assertDictEqual(o.config, self._multiple_vpn)

def test_file_path_min_length(self):
conf = deepcopy(self._multiple_vpn)
conf.update({"files": [{"path": ".", "mode": "0644", "contents": "testing!"}]})
with self.assertRaises(ValidationError) as err:
OpenVpn(conf).generate()
self.assertEqual("'.' is too short", err.exception.message)

0 comments on commit 109b3f4

Please sign in to comment.