fix: resolve CI test failures — schema, OPC mocking, download auth, router reloads

Fix 20 pre-existing test failures:
- Update mock conversation DB schema with missing columns
- Add in-memory OPC database mock to avoid PostgreSQL dependency in CI
- Fix file download endpoint to check auth before revealing file existence
- Reload routers.system and routers.security in test_app for fresh config
- Reset cached Docker client in security router between tests
- Fix websocket auth test to properly check for connection rejection

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Gan, Jimmy
2026-05-03 21:57:00 +08:00
parent e8534728ef
commit 56a8ff28ad
3 changed files with 225 additions and 14 deletions
@@ -6,10 +6,11 @@ from unittest.mock import AsyncMock, MagicMock, patch
def test_terminal_ws_requires_authentication(test_app):
"""Test terminal WebSocket requires authentication"""
# Try to connect without auth cookie
with test_app.websocket_connect("/api/terminal/ws?host=nas") as websocket:
# Should be rejected
pass
# Connection without auth should be rejected — either the upgrade fails
# (403) or the server immediately closes the connection after upgrade.
with pytest.raises(Exception):
with test_app.websocket_connect("/api/terminal/ws?host=nas") as websocket:
websocket.receive_text()
def test_terminal_ws_rejects_invalid_token(test_app):