Skip to content

Commit 109b3f4

Browse files
authored
[fix] File path shouldn't be allowed to be empty #166
Fixes #166
1 parent eecbba4 commit 109b3f4

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

netjsonconfig/schema.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,7 @@
939939
"type": "string",
940940
"description": "filesystem path",
941941
"propertyOrder": 1,
942+
"minLength": 2,
942943
},
943944
"mode": {
944945
"type": "string",

tests/openvpn/test_parser.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from copy import deepcopy
44

55
from netjsonconfig import OpenVpn
6-
from netjsonconfig.exceptions import ParseError
6+
from netjsonconfig.exceptions import ParseError, ValidationError
77

88

99
class TestParser(unittest.TestCase):
@@ -159,3 +159,10 @@ def test_parse_tar_file(self):
159159
OpenVpn(native=open('/tmp/test.tar.gz'))
160160
os.remove('/tmp/test.tar.gz')
161161
self.assertDictEqual(o.config, self._multiple_vpn)
162+
163+
def test_file_path_min_length(self):
164+
conf = deepcopy(self._multiple_vpn)
165+
conf.update({"files": [{"path": ".", "mode": "0644", "contents": "testing!"}]})
166+
with self.assertRaises(ValidationError) as err:
167+
OpenVpn(conf).generate()
168+
self.assertEqual("'.' is too short", err.exception.message)

0 commit comments

Comments
 (0)