mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-21 23:46:18 -05:00
controller: address hotspot protocol review findings
- Reset a saved protocol the newly probed device does not support instead of offering it (both UIs); a successful probe is authoritative, the saved value is only kept when probing fails. - Ignore out-of-order protocol probe responses when switching devices quickly (both UIs). - Verify the WPA2 rollback after a failed WPA3 activation; report that the hotspot may be down instead of claiming the revert succeeded. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
8687816b84
commit
2baa9cbd2e
5 changed files with 67 additions and 12 deletions
|
|
@ -1451,16 +1451,32 @@ function HotspotSettingsForm() {
|
|||
if (!form.device) {
|
||||
return;
|
||||
}
|
||||
// Ignore out-of-order responses when the user switches devices quickly.
|
||||
let cancelled = false;
|
||||
const fetchProtocols = async () => {
|
||||
try {
|
||||
const response = await getHotspotProtocols(form.device);
|
||||
setProtocols(response.protocols || []);
|
||||
if (cancelled) {
|
||||
return;
|
||||
}
|
||||
const supported = response.protocols || [];
|
||||
setProtocols(supported);
|
||||
// Reset a selection the probed device does not support (e.g. WPA3 kept
|
||||
// after switching to a WPA2-only adapter).
|
||||
if (supported.length) {
|
||||
setForm(f => supported.includes(f.protocol) ? f : {...f, protocol: supported[0]});
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to fetch hotspot protocols', e);
|
||||
setProtocols([]);
|
||||
if (!cancelled) {
|
||||
console.error('Failed to fetch hotspot protocols', e);
|
||||
setProtocols([]);
|
||||
}
|
||||
}
|
||||
};
|
||||
fetchProtocols();
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [form.device]);
|
||||
|
||||
const handleSave = async () => {
|
||||
|
|
|
|||
|
|
@ -208,6 +208,19 @@ describe('ControllerPage', () => {
|
|||
});
|
||||
});
|
||||
|
||||
test('a saved protocol the device does not support is reset to a supported one', async () => {
|
||||
const controllerApi = require('../../api/controller');
|
||||
controllerApi.getHotspotSettings.mockResolvedValue(
|
||||
{device: 'wlan0', ssid: 'WROLPi', password: 'wrolpi hotspot', protocol: 'wpa3'});
|
||||
controllerApi.getHotspotProtocols.mockResolvedValue({device: 'wlan0', protocols: ['wpa2']});
|
||||
renderControllerPage();
|
||||
// The stale WPA3 selection is replaced by the only protocol the device supports.
|
||||
await waitFor(() => {
|
||||
expect(screen.getAllByText('WPA2 (most compatible)').length).toBeGreaterThan(0);
|
||||
});
|
||||
expect(screen.queryByText('WPA3')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('hotspot protocol dropdown only offers WPA2 on a Raspberry Pi', async () => {
|
||||
const {getHotspotProtocols} = require('../../api/controller');
|
||||
getHotspotProtocols.mockResolvedValue({device: 'wlan0', protocols: ['wpa2']});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue