Permalink
Browse files

[OpenWrt] Added regexp pattern to maclist elements

  • Loading branch information...
nemesisdesign committed Mar 24, 2016
1 parent 26b62dd commit 11da509a5899368f4ff46de2b9bd98532dce4c3f
Showing with 37 additions and 1 deletion.
  1. +2 −1 netjsonconfig/backends/openwrt/schema.py
  2. +35 −0 tests/openwrt/test_wireless.py
@@ -112,8 +112,9 @@
"items": {
"type": "string",
"title": "MAC address",
"maxLength": 17,
"pattern": "^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$",
"minLength": 17,
"maxLength": 17,
}
}
}
@@ -1000,6 +1000,41 @@ def test_wifi_macfilter(self):
""")
self.assertEqual(o.render(), expected)
def test_maclist_format(self):
o = OpenWrt({
"interfaces": [
{
"name": "wlan0",
"type": "wireless",
"wireless": {
"radio": "radio0",
"mode": "access_point",
"ssid": "MyWifiAP",
"macfilter": "deny",
"maclist": [
"E8:94:F6:33:8C:1D",
]
}
}
]
})
o.validate()
# too short
o.config['interfaces'][0]['wireless']['maclist'][0] = '00:11:22:33:44'
with self.assertRaises(ValidationError):
o.validate()
# valid
o.config['interfaces'][0]['wireless']['maclist'][0] = '00-11-22-33-44-55'
o.validate()
# should not be valid
o.config['interfaces'][0]['wireless']['maclist'][0] = '00:11:22:33:44:ZY'
with self.assertRaises(ValidationError):
o.validate()
# empty is not valid
o.config['interfaces'][0]['wireless']['maclist'][0] = ''
with self.assertRaises(ValidationError):
o.validate()
def test_wds_bridge(self):
o = OpenWrt({
"interfaces": [

0 comments on commit 11da509

Please sign in to comment.