feat: read radio1 AP state in wifi get_ap

This commit is contained in:
2026-08-17 23:17:57 -05:00
parent 27df97ec43
commit 7aff767f2a
2 changed files with 127 additions and 19 deletions
+88
View File
@@ -71,5 +71,93 @@ class BandAuxTest(unittest.TestCase):
set(range(52, 65, 4)) | set(range(100, 145, 4)))
def ctx(body=None):
return type('C', (), {'body': body, 'args': (), 'query': {}})()
class GetApRadio1Test(unittest.TestCase):
def _uci(self, section):
table = {
'radio0': {'type': 'wifi-device', 'band': '2g', 'channel': '11',
'htmode': 'HT20', 'country': 'US'},
'radio1': {'type': 'wifi-device', 'band': '5g', 'channel': 'auto',
'htmode': 'VHT80', 'country': 'US'},
'wlan0open': {'device': 'radio0', 'mode': 'ap', 'ssid': 'pager-open',
'disabled': '0', 'hidden': '0', 'encryption': 'none',
'channel': '11'},
'wlan0wpa': {'device': 'radio0', 'mode': 'ap', 'ssid': 'Service',
'disabled': '0', 'hidden': '0', 'encryption': 'psk2',
'channel': '1', 'key': 'testpass123'},
'wlan1open': {'device': 'radio1', 'mode': 'ap', 'ssid': 'CorpGuest',
'disabled': '0', 'hidden': '0', 'encryption': 'none',
'channel': '36'},
'wlan1wpa': {'device': 'radio1', 'mode': 'ap', 'ssid': 'Corp',
'disabled': '0', 'hidden': '0', 'encryption': 'sae',
'channel': '1', 'key': 'secret123'},
}
return dict(table.get(section, {}))
def setUp(self):
server._uci_wifi_iface = lambda name: self._uci(name)
server.daemon_sock_call = lambda method, path, body=None, timeout=10: (
404, {'error': 'not found'})
def test_open_reports_radio1_when_present(self):
status, payload = server.h_pineap_wifi_get_ap(ctx())
self.assertEqual(status, 200)
self.assertEqual(payload['open']['ssid'], 'CorpGuest')
self.assertEqual(payload['open']['channel'], 36)
self.assertEqual(payload['open']['country'], 'US')
def test_wpa_reports_radio1_when_present(self):
status, payload = server.h_pineap_wifi_get_ap(ctx())
self.assertEqual(status, 200)
self.assertEqual(payload['wpa']['ssid'], 'Corp')
self.assertEqual(payload['wpa']['enctype'], 'sae')
self.assertEqual(payload['wpa']['channel'], 1)
def test_radio1_info(self):
status, payload = server.h_pineap_wifi_get_ap(ctx())
self.assertEqual(status, 200)
self.assertEqual(payload['radio1']['band'], server.BAND_5G)
self.assertEqual(payload['radio1']['channel'], 'auto')
class GetApRadio1AbsentTest(unittest.TestCase):
"""Regression: no radio1 AP sections -> today's 2.4GHz behavior."""
def _uci(self, section):
table = {
'radio0': {'type': 'wifi-device', 'band': '2g', 'channel': '11',
'htmode': 'HT20', 'country': 'US'},
'radio1': {'type': 'wifi-device', 'band': '5g', 'channel': 'auto',
'htmode': 'VHT80', 'country': 'US'},
'wlan0open': {'device': 'radio0', 'mode': 'ap', 'ssid': 'pager-open',
'disabled': '0', 'hidden': '0', 'encryption': 'none',
'channel': '11'},
'wlan0wpa': {'device': 'radio0', 'mode': 'ap', 'ssid': 'Service',
'disabled': '0', 'hidden': '0', 'encryption': 'psk2',
'channel': '1', 'key': 'testpass123'},
}
return dict(table.get(section, {}))
def setUp(self):
server._uci_wifi_iface = lambda name: self._uci(name)
server.daemon_sock_call = lambda method, path, body=None, timeout=10: (
404, {'error': 'not found'})
def test_open_uses_wlan0open(self):
status, payload = server.h_pineap_wifi_get_ap(ctx())
self.assertEqual(status, 200)
self.assertEqual(payload['open']['ssid'], 'pager-open')
self.assertEqual(payload['open']['channel'], 11)
def test_wpa_uses_wlan0wpa(self):
status, payload = server.h_pineap_wifi_get_ap(ctx())
self.assertEqual(status, 200)
self.assertEqual(payload['wpa']['ssid'], 'Service')
self.assertEqual(payload['wpa']['channel'], 1)
if __name__ == '__main__':
unittest.main()