fix: fall back to radio channel when AP iface lacks channel

This commit is contained in:
2026-08-17 23:21:09 -05:00
parent 7aff767f2a
commit b2098bae7d
2 changed files with 36 additions and 2 deletions
@@ -1658,8 +1658,9 @@ def h_pineap_wifi_get_ap(ctx):
except (TypeError, ValueError): except (TypeError, ValueError):
return None return None
open_channel = _chan(open_cfg) radio_channel = _chan(radio_cfg)
wpa_channel = _chan(wpa_cfg) open_channel = _chan(open_cfg) or radio_channel
wpa_channel = _chan(wpa_cfg) or radio_channel
encryption = wpa_cfg.get('encryption') or '' encryption = wpa_cfg.get('encryption') or ''
if encryption.startswith('psk2'): if encryption.startswith('psk2'):
encryption = 'psk2' encryption = 'psk2'
+33
View File
@@ -159,5 +159,38 @@ class GetApRadio1AbsentTest(unittest.TestCase):
self.assertEqual(payload['wpa']['channel'], 1) 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__': if __name__ == '__main__':
unittest.main() unittest.main()