Skip to content

Commit

Permalink
[schema] Added pattern for BSSID attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
nemesifier committed Mar 24, 2016
1 parent 468a5df commit 26b62dd
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions netjsonconfig/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
32 changes: 32 additions & 0 deletions tests/openwrt/test_wireless.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.