fix(tests): repair 39 broken tests after auth/authz hardening
- Clean Release API (33 tests): added get_current_user dependency override with mock admin user in _make_client — router now requires has_permission - WebSocket endpoints (23 tests): added _authorize_websocket mock alongside existing _authenticate_websocket mock — RBAC check was added before accept() - Lifespan (1 test): relaxed commit assert_called_once → assert_called — RBAC permission catalog sync also calls commit on the same mock All 7445 backend tests pass (0 failures).
This commit is contained in:
@@ -81,6 +81,7 @@ class TestWebSocketEndpointFull:
|
||||
async def ss(t): return sq
|
||||
with (
|
||||
patch("src.app._authenticate_websocket", return_value=True),
|
||||
patch("src.app._authorize_websocket", return_value=True),
|
||||
patch("src.app.get_task_manager") as mg,
|
||||
):
|
||||
tm = _make_task_manager_mock(task=task, logs=[log])
|
||||
@@ -105,6 +106,7 @@ class TestWebSocketEndpointFull:
|
||||
async def ss(t): return sq
|
||||
with (
|
||||
patch("src.app._authenticate_websocket", return_value=True),
|
||||
patch("src.app._authorize_websocket", return_value=True),
|
||||
patch("src.app.get_task_manager") as mg,
|
||||
):
|
||||
tm = _make_task_manager_mock(task=task, logs=[plug, super])
|
||||
@@ -129,6 +131,7 @@ class TestWebSocketEndpointFull:
|
||||
async def ss(t): return sq
|
||||
with (
|
||||
patch("src.app._authenticate_websocket", return_value=True),
|
||||
patch("src.app._authorize_websocket", return_value=True),
|
||||
patch("src.app.get_task_manager") as mg,
|
||||
):
|
||||
tm = _make_task_manager_mock(task=task, logs=[dbg, inf])
|
||||
@@ -153,6 +156,7 @@ class TestWebSocketEndpointFull:
|
||||
async def ss(t): return sq
|
||||
with (
|
||||
patch("src.app._authenticate_websocket", return_value=True),
|
||||
patch("src.app._authorize_websocket", return_value=True),
|
||||
patch("src.app.get_task_manager") as mg,
|
||||
):
|
||||
tm = _make_task_manager_mock(task=task, logs=[])
|
||||
@@ -175,6 +179,7 @@ class TestWebSocketEndpointFull:
|
||||
async def ss(t): return sq
|
||||
with (
|
||||
patch("src.app._authenticate_websocket", return_value=True),
|
||||
patch("src.app._authorize_websocket", return_value=True),
|
||||
patch("src.app.get_task_manager") as mg,
|
||||
):
|
||||
tm = _make_task_manager_mock(task=task, logs=[])
|
||||
@@ -198,6 +203,7 @@ class TestWebSocketEndpointFull:
|
||||
async def ss(t): return sq
|
||||
with (
|
||||
patch("src.app._authenticate_websocket", return_value=True),
|
||||
patch("src.app._authorize_websocket", return_value=True),
|
||||
patch("src.app.get_task_manager") as mg,
|
||||
):
|
||||
tm = _make_task_manager_mock(task=task, logs=[term])
|
||||
@@ -252,6 +258,7 @@ class TestWebSocketMainLoopCoverage:
|
||||
async def ss(t): return sq
|
||||
with (
|
||||
patch("src.app._authenticate_websocket", return_value=True),
|
||||
patch("src.app._authorize_websocket", return_value=True),
|
||||
patch("src.app.get_task_manager") as mg,
|
||||
):
|
||||
tm = _make_task_manager_mock(task=task, logs=[])
|
||||
@@ -290,6 +297,7 @@ class TestWebSocketMainLoopCoverage:
|
||||
async def ss(t): return sq
|
||||
with (
|
||||
patch("src.app._authenticate_websocket", return_value=True),
|
||||
patch("src.app._authorize_websocket", return_value=True),
|
||||
patch("src.app.get_task_manager") as mg,
|
||||
):
|
||||
tm = _make_task_manager_mock(task=task, logs=[])
|
||||
@@ -319,6 +327,7 @@ class TestWebSocketMainLoopCoverage:
|
||||
async def ss(t): return sq
|
||||
with (
|
||||
patch("src.app._authenticate_websocket", return_value=True),
|
||||
patch("src.app._authorize_websocket", return_value=True),
|
||||
patch("src.app.get_task_manager") as mg,
|
||||
patch("src.app.logger") as mock_logger,
|
||||
):
|
||||
@@ -345,6 +354,7 @@ class TestWebSocketMainLoopExceptions:
|
||||
async def ss(t): return sq
|
||||
with (
|
||||
patch("src.app._authenticate_websocket", return_value=True),
|
||||
patch("src.app._authorize_websocket", return_value=True),
|
||||
patch("src.app.get_task_manager") as mg,
|
||||
):
|
||||
tm = _make_task_manager_mock(task=task, logs=[])
|
||||
@@ -365,6 +375,7 @@ class TestWebSocketMainLoopExceptions:
|
||||
async def sub(): return q
|
||||
with (
|
||||
patch("src.app._authenticate_websocket", return_value=True),
|
||||
patch("src.app._authorize_websocket", return_value=True),
|
||||
patch("src.app.get_task_manager") as mg,
|
||||
):
|
||||
tm = MagicMock(); tm.subscribe_task_events = sub; tm.unsubscribe_task_events = MagicMock()
|
||||
@@ -384,6 +395,7 @@ class TestWebSocketMainLoopExceptions:
|
||||
async def sub(): return q
|
||||
with (
|
||||
patch("src.app._authenticate_websocket", return_value=True),
|
||||
patch("src.app._authorize_websocket", return_value=True),
|
||||
patch("src.app.get_task_manager") as mg,
|
||||
):
|
||||
tm = MagicMock(); tm.subscribe_maintenance_events = sub; tm.unsubscribe_maintenance_events = MagicMock()
|
||||
@@ -403,6 +415,7 @@ class TestWebSocketMainLoopExceptions:
|
||||
async def sub(e): return q
|
||||
with (
|
||||
patch("src.app._authenticate_websocket", return_value=True),
|
||||
patch("src.app._authorize_websocket", return_value=True),
|
||||
patch("src.app.get_task_manager") as mg,
|
||||
):
|
||||
tm = MagicMock(); tm.subscribe_dataset_events = sub; tm.unsubscribe_dataset_events = MagicMock()
|
||||
|
||||
Reference in New Issue
Block a user