fix: make keypair generation async to avoid blocking the event loop
generate_keypair() used synchronous subprocess.run() which blocked the NiceGUI event loop during wg genkey/pubkey calls. This caused WebSocket disconnects, page reloads, and the config dialog never appearing after device creation. Switched to asyncio.create_subprocess_exec so the event loop stays responsive while waiting for the wg CLI.
This commit is contained in:
parent
e51c53f247
commit
92554d4089
7 changed files with 31 additions and 22 deletions
|
|
@ -1,6 +1,6 @@
|
|||
"""End-to-end tests for device management UI using NiceGUI's User fixture."""
|
||||
|
||||
from unittest.mock import patch
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
import pytest
|
||||
from nicegui.testing import User
|
||||
|
|
@ -25,7 +25,7 @@ async def _login(user: User):
|
|||
@pytest.mark.parametrize("user", [{"storage": {}}], indirect=True)
|
||||
async def test_add_device_via_ui(user: User, test_user: UserModel):
|
||||
"""Test the full flow: login → devices → add device → see it in table."""
|
||||
with patch("wiregui.pages.devices.generate_keypair", return_value=(FAKE_PRIVATE_KEY, FAKE_PUBLIC_KEY)), \
|
||||
with patch("wiregui.pages.devices.generate_keypair", new_callable=AsyncMock, return_value=(FAKE_PRIVATE_KEY, FAKE_PUBLIC_KEY)), \
|
||||
patch("wiregui.pages.devices.generate_preshared_key", return_value="cHJlc2hhcmVkMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDA="):
|
||||
|
||||
await _login(user)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue