Skip to content

Commit

Permalink
[schema] Validate interface ipv4 address format #42
Browse files Browse the repository at this point in the history
  • Loading branch information
nemesifier committed Apr 3, 2016
1 parent ef8c296 commit 2f23cfd
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/openwrt/test_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,25 @@ def test_general_hostname(self):
o.config['general']['hostname'] = 'valid'
o.validate()

def test_interface_ipv4(self):
o = OpenWrt({
"interfaces": [
{
"name": "eth0",
"type": "ethernet",
"addresses": [
{
"family": "ipv4",
"proto": "static",
"address": "10.0.0.1",
"mask": 28
}
]
}
]
})
o.validate()
# invalid ipv4
o.config['interfaces'][0]['addresses'][0]['address'] = '127_0_0_1'
with self.assertRaises(ValidationError):
o.validate()

0 comments on commit 2f23cfd

Please sign in to comment.