diff --git a/payload/user/remote_access/pager-webui/server.py b/payload/user/remote_access/pager-webui/server.py index bd1b099..5543fae 100644 --- a/payload/user/remote_access/pager-webui/server.py +++ b/payload/user/remote_access/pager-webui/server.py @@ -1658,8 +1658,9 @@ def h_pineap_wifi_get_ap(ctx): except (TypeError, ValueError): return None - open_channel = _chan(open_cfg) - wpa_channel = _chan(wpa_cfg) + radio_channel = _chan(radio_cfg) + open_channel = _chan(open_cfg) or radio_channel + wpa_channel = _chan(wpa_cfg) or radio_channel encryption = wpa_cfg.get('encryption') or '' if encryption.startswith('psk2'): encryption = 'psk2' diff --git a/tests/test_pineap_bands.py b/tests/test_pineap_bands.py index caa3612..9606b4d 100644 --- a/tests/test_pineap_bands.py +++ b/tests/test_pineap_bands.py @@ -159,5 +159,38 @@ class GetApRadio1AbsentTest(unittest.TestCase): self.assertEqual(payload['wpa']['channel'], 1) +class GetApRadioChannelFallbackTest(unittest.TestCase): + """Regression: iface without a channel option inherits the radio channel.""" + + 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'}, + 'wlan0wpa': {'device': 'radio0', 'mode': 'ap', 'ssid': 'Service', + 'disabled': '0', 'hidden': '0', 'encryption': 'psk2', + '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_falls_back_to_radio_channel(self): + status, payload = server.h_pineap_wifi_get_ap(ctx()) + self.assertEqual(status, 200) + self.assertEqual(payload['open']['channel'], 11) + + def test_wpa_falls_back_to_radio_channel(self): + status, payload = server.h_pineap_wifi_get_ap(ctx()) + self.assertEqual(status, 200) + self.assertEqual(payload['wpa']['channel'], 11) + + if __name__ == '__main__': unittest.main()