-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
addc51f
commit d8ec7a3
Showing
5 changed files
with
182 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
128 changes: 128 additions & 0 deletions
128
openwrt-openwisp-monitoring/tests/test_files/wireless_data.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
local test_data = {} | ||
|
||
test_data.wireless_status={ | ||
radio0 = { | ||
autostart = true, | ||
config = { | ||
channel = "11", | ||
htmode = "HT20", | ||
hwmode = "11g", | ||
path = "platform/10300000.wmac" | ||
}, | ||
disabled = false, | ||
interfaces = { { | ||
config = { | ||
encryption = "none", | ||
mode = "ap", | ||
network = { "lan" }, | ||
ssid = "OpenWrt" | ||
}, | ||
ifname = "wlan0-1", | ||
section = "default_radio0" | ||
}, { | ||
config = { | ||
encryption = "psk2", | ||
key = "95535210", | ||
mode = "sta", | ||
network = { "wwan" }, | ||
ssid = "DIR-615-5A5B" | ||
}, | ||
ifname = "wlan0", | ||
section = "wifinet2" | ||
} }, | ||
pending = false, | ||
retry_setup_failed = false, | ||
up = true | ||
}, | ||
radio1 = { | ||
autostart = true, | ||
config = { | ||
channel = "36", | ||
htmode = "VHT80", | ||
hwmode = "11a", | ||
path = "pci0000:00/0000:00:00.0/0000:01:00.0" | ||
}, | ||
disabled = false, | ||
interfaces = { { | ||
config = { | ||
encryption = "none", | ||
mode = "ap", | ||
network = { "lan" }, | ||
ssid = "OpenWrt" | ||
}, | ||
ifname = "wlan1", | ||
section = "default_radio1" | ||
} }, | ||
pending = false, | ||
retry_setup_failed = false, | ||
up = true | ||
} | ||
} | ||
|
||
test_data.wlan1_clients = { | ||
["20:a6:0c:b2:da:10"] = { | ||
aid = 2, | ||
assoc = true, | ||
auth = true, | ||
authorized = true, | ||
ht = true, | ||
mfp = false, | ||
preauth = false, | ||
rrm = { 0, 0, 0, 0, 0 }, | ||
vht = true, | ||
wds = false, | ||
wmm = true, | ||
wps = false | ||
}, | ||
["98:3b:8f:98:b1:fb"] = { | ||
aid = 1, | ||
assoc = true, | ||
auth = true, | ||
authorized = true, | ||
ht = true, | ||
mfp = false, | ||
preauth = false, | ||
rrm = { 0, 0, 0, 0, 0 }, | ||
vht = true, | ||
wds = false, | ||
wmm = true, | ||
wps = false | ||
} | ||
} | ||
|
||
test_data.wlan0_clients = {} | ||
|
||
test_data.parsed_clients = { | ||
{ | ||
aid=1, | ||
assoc=true, | ||
auth=true, | ||
authorized=true, | ||
ht=true, | ||
mac="98:3b:8f:98:b1:fb", | ||
mfp=false, | ||
preauth=false, | ||
rrm={0, 0, 0, 0, 0}, | ||
vht=true, | ||
wds=false, | ||
wmm=true, | ||
wps=false | ||
}, | ||
{ | ||
aid=2, | ||
assoc=true, | ||
auth=true, | ||
authorized=true, | ||
ht=true, | ||
mac="20:a6:0c:b2:da:10", | ||
mfp=false, | ||
preauth=false, | ||
rrm={0, 0, 0, 0, 0}, | ||
vht=true, | ||
wds=false, | ||
wmm=true, | ||
wps=false | ||
} | ||
} | ||
|
||
return test_data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package.path = package.path .. ";../files/lib/openwisp/?.lua" | ||
|
||
local wifi_data = require('test_files/wireless_data') | ||
|
||
local luaunit = require('luaunit') | ||
local wifi_functions = require('wifi') | ||
|
||
TestWifi = { | ||
setUp = function() | ||
end, | ||
tearDown = function() | ||
end | ||
} | ||
|
||
|
||
function TestWifi.test_parse_hostapd_clients() | ||
luaunit.assertEquals(wifi_functions.parse_hostapd_clients(wifi_data.wlan1_clients), wifi_data.parsed_clients) | ||
luaunit.assertEquals(wifi_functions.parse_hostapd_clients(wifi_data.wlan0_clients), {}) | ||
end | ||
|
||
function TestWifi.test_netjson_clients() | ||
luaunit.assertEquals(wifi_functions.netjson_clients(wifi_data.wlan1_clients, false), wifi_data.parsed_clients) | ||
luaunit.assertEquals(wifi_functions.netjson_clients(wifi_data.wlan0_clients, false), {}) | ||
end | ||
|
||
|
||
os.exit( luaunit.LuaUnit.run() ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters