mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-29 19:36:20 -05:00
controller: selectable hotspot protocol (WPA2/WPA3) with device capability probing
Probe the selected WiFi device with iw to determine which hotspot protocols it can host: WPA2 requires AP mode; WPA3 requires SAE in AP mode (SAE_OFFLOAD_AP, or a mac80211 driver with the CMAC cipher for software SAE). The Raspberry Pi's brcmfmac supports neither, so Pis correctly offer WPA2 only (verified against real Pi 4/Pi 5 iw output). The protocol is saved as hotspot.protocol in controller.yaml. enable_hotspot() now always sets the Hotspot connection's key-mgmt explicitly (sae + required PMF for WPA3) so a reused profile cannot keep a stale protocol, and reverts to WPA2 if the driver rejects SAE. New GET /api/hotspot/protocols endpoint; protocol dropdowns added to both the ControllerPage React UI and the fallback controller UI. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
2355095391
commit
8687816b84
10 changed files with 545 additions and 16 deletions
|
|
@ -65,6 +65,10 @@ jest.mock('../../api/controller', () => ({
|
|||
removeFstabEntry: jest.fn().mockResolvedValue({success: true}),
|
||||
restartServices: jest.fn().mockResolvedValue({success: true}),
|
||||
getSambaStatus: jest.fn().mockResolvedValue({enabled: false, available: true, shares: []}),
|
||||
getHotspotSettings: jest.fn(),
|
||||
getHotspotDevices: jest.fn(),
|
||||
getHotspotProtocols: jest.fn(),
|
||||
updateHotspotSettings: jest.fn(),
|
||||
addSambaShare: jest.fn().mockResolvedValue({success: true}),
|
||||
removeSambaShare: jest.fn().mockResolvedValue({success: true}),
|
||||
}));
|
||||
|
|
@ -141,6 +145,14 @@ describe('ControllerPage', () => {
|
|||
// Reset useDockerized to false for regular tests
|
||||
const {useDockerized} = require('../../hooks/customHooks');
|
||||
useDockerized.mockReturnValue(false);
|
||||
// resetMocks clears module-factory implementations, so configure hotspot mocks here.
|
||||
const controllerApi = require('../../api/controller');
|
||||
controllerApi.getHotspotSettings.mockResolvedValue(
|
||||
{device: 'wlan0', ssid: 'WROLPi', password: 'wrolpi hotspot', protocol: 'wpa2'});
|
||||
controllerApi.getHotspotDevices.mockResolvedValue({devices: ['wlan0']});
|
||||
controllerApi.getHotspotProtocols.mockResolvedValue({device: 'wlan0', protocols: ['wpa2', 'wpa3']});
|
||||
controllerApi.updateHotspotSettings.mockResolvedValue(
|
||||
{device: 'wlan0', ssid: 'WROLPi', password: 'wrolpi hotspot', protocol: 'wpa2'});
|
||||
});
|
||||
|
||||
test('renders Services section', async () => {
|
||||
|
|
@ -181,6 +193,34 @@ describe('ControllerPage', () => {
|
|||
});
|
||||
});
|
||||
|
||||
test('hotspot protocol dropdown lists the protocols supported by the device', async () => {
|
||||
const {getHotspotProtocols} = require('../../api/controller');
|
||||
renderControllerPage();
|
||||
await waitFor(() => {
|
||||
expect(getHotspotProtocols).toHaveBeenCalledWith('wlan0');
|
||||
});
|
||||
expect(screen.getByText('Hotspot Protocol')).toBeInTheDocument();
|
||||
// The saved protocol is selected; WPA3 is offered because the device supports it.
|
||||
// Semantic UI renders the selected value as both the dropdown text and an option.
|
||||
await waitFor(() => {
|
||||
expect(screen.getAllByText('WPA2 (most compatible)').length).toBeGreaterThan(0);
|
||||
expect(screen.getAllByText('WPA3').length).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
test('hotspot protocol dropdown only offers WPA2 on a Raspberry Pi', async () => {
|
||||
const {getHotspotProtocols} = require('../../api/controller');
|
||||
getHotspotProtocols.mockResolvedValue({device: 'wlan0', protocols: ['wpa2']});
|
||||
renderControllerPage();
|
||||
await waitFor(() => {
|
||||
expect(getHotspotProtocols).toHaveBeenCalledWith('wlan0');
|
||||
});
|
||||
await waitFor(() => {
|
||||
expect(screen.getAllByText('WPA2 (most compatible)').length).toBeGreaterThan(0);
|
||||
});
|
||||
expect(screen.queryByText('WPA3')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('DiskSection primary unmount', () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue