Skip to content

Commit

Permalink
[schema] Validate dns_search hostname format #42
Browse files Browse the repository at this point in the history
  • Loading branch information
nemesifier committed Apr 4, 2016
1 parent abb63bd commit f1116f0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion netjsonconfig/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,8 @@
"propertyOrder": 5,
"items": {
"title": "Domain",
"type": "string"
"type": "string",
"format": "hostname"
}
},
"routes": {
Expand Down
10 changes: 10 additions & 0 deletions tests/openwrt/test_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,13 @@ def test_ntp_servers_hostname(self):
o.config['ntp']['server'][0] = 'totally/wrong'
with self.assertRaises(ValidationError):
o.validate()

def test_dns_search_hostname(self):
o = OpenWrt({
"dns_search": ['openwisp.org', 'test.netjson.org']
})
o.validate()
# invalid hostname
o.config['dns_search'].append('very/wrong')
with self.assertRaises(ValidationError):
o.validate()

0 comments on commit f1116f0

Please sign in to comment.