Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
[schema] Validate interface ipv4 address format #42
- Loading branch information
Showing
with
22 additions
and
0 deletions.
-
+22
−0
tests/openwrt/test_formats.py
|
@@ -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() |