Skip to content
Permalink
Browse files

[schema] Added pattern for BSSID attribute

  • Loading branch information
nemesisdesign committed Mar 24, 2016
1 parent 468a5df commit 26b62dddf0cbcfe4c0f8892488c12d5f59ac0c39
Showing with 33 additions and 0 deletions.
  1. +1 −0 netjsonconfig/schema.py
  2. +32 −0 tests/openwrt/test_wireless.py
@@ -331,6 +331,7 @@
"bssid": {
"type": "string",
"title": "BSSID",
"pattern": "^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$",
"minLength": 17,
"maxLength": 17,
"propertyOrder": 4,
@@ -1130,3 +1130,35 @@ def test_mesh_80211s(self):
option network 'lan'
""")
self.assertEqual(o.render(), expected)

def test_bssid_format(self):
o = OpenWrt({
"interfaces": [
{
"name": "wlan0",
"type": "wireless",
"wireless": {
"radio": "radio1",
"mode": "adhoc",
"ssid": "adhoc-ssid",
"bssid": "00:11:22:33:44:55"
}
}
]
})
o.validate()
# too short
o.config['interfaces'][0]['wireless']['bssid'] = '00:11:22:33:44'
with self.assertRaises(ValidationError):
o.validate()
# valid
o.config['interfaces'][0]['wireless']['bssid'] = '00-11-22-33-44-55'
o.validate()
# should not be valid
o.config['interfaces'][0]['wireless']['bssid'] = '00:11:22:33:44:ZY'
with self.assertRaises(ValidationError):
o.validate()
# empty is not valid
o.config['interfaces'][0]['wireless']['bssid'] = ''
with self.assertRaises(ValidationError):
o.validate()

0 comments on commit 26b62dd

Please sign in to comment.
You can’t perform that action at this time.