mirror of
https://github.com/eigent-ai/eigent.git
synced 2026-04-29 04:00:09 +00:00
Feat: Server refactor v1 (#1509)
Some checks are pending
Pre-commit / pre-commit (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
CodeQL Advanced / Analyze (python) (push) Waiting to run
Test / Run Python Tests (push) Waiting to run
Some checks are pending
Pre-commit / pre-commit (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
CodeQL Advanced / Analyze (python) (push) Waiting to run
Test / Run Python Tests (push) Waiting to run
This commit is contained in:
parent
1e542f9d27
commit
712f20a8fa
179 changed files with 5593 additions and 6063 deletions
|
|
@ -16,7 +16,7 @@ import inspect
|
|||
|
||||
import pytest
|
||||
|
||||
from app.controller.chat.share_controller import (
|
||||
from app.domains.chat.api.share_controller import (
|
||||
create_share_link,
|
||||
get_share_info,
|
||||
share_playback,
|
||||
|
|
@ -35,7 +35,7 @@ class TestAuthMustNoneTokenHandling:
|
|||
def test_auth_must_has_none_type_annotation(self):
|
||||
"""auth_must should accept Optional[str] since oauth2_scheme
|
||||
may return None with auto_error=False."""
|
||||
from app.component.auth import auth_must
|
||||
from app.shared.auth.user_auth import auth_must
|
||||
|
||||
sig = inspect.signature(auth_must)
|
||||
token_param = sig.parameters["token"]
|
||||
|
|
@ -47,43 +47,39 @@ class TestAuthMustNoneTokenHandling:
|
|||
"""auth_must should raise TokenException immediately when
|
||||
token is None, not pass it to jwt.decode()."""
|
||||
import asyncio
|
||||
from unittest.mock import MagicMock, patch
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from app.component.auth import auth_must
|
||||
from app.exception.exception import TokenException
|
||||
from app.shared.auth.user_auth import auth_must
|
||||
from app.shared.exception import TokenException
|
||||
|
||||
mock_session = MagicMock()
|
||||
|
||||
with pytest.raises(TokenException):
|
||||
asyncio.run(auth_must(token=None, session=mock_session))
|
||||
asyncio.run(auth_must(token=None, db_session=mock_session))
|
||||
|
||||
def test_auth_must_does_not_call_decode_on_none(self):
|
||||
"""Verify jwt.decode is never called with None token."""
|
||||
import asyncio
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from app.component.auth import auth_must
|
||||
from app.shared.auth.user_auth import auth_must
|
||||
|
||||
mock_session = MagicMock()
|
||||
|
||||
with patch("app.component.auth.Auth.decode_token") as mock_decode:
|
||||
with patch("app.shared.auth.user_auth.V1UserAuth.decode_token") as mock_decode:
|
||||
try:
|
||||
asyncio.run(auth_must(token=None, session=mock_session))
|
||||
asyncio.run(auth_must(token=None, db_session=mock_session))
|
||||
except Exception:
|
||||
pass
|
||||
mock_decode.assert_not_called()
|
||||
|
||||
|
||||
class TestSnapshotEndpointAuthRequirements:
|
||||
"""Tests verifying that all snapshot CRUD endpoints require authentication.
|
||||
|
||||
The list endpoint was previously missing the auth dependency, allowing
|
||||
unauthenticated users to enumerate all snapshots across all users.
|
||||
"""
|
||||
"""Tests verifying that all snapshot CRUD endpoints require authentication."""
|
||||
|
||||
def test_list_snapshots_requires_auth_dependency(self):
|
||||
"""GET /snapshots must include auth_must as a dependency."""
|
||||
from app.controller.chat.snapshot_controller import list_chat_snapshots
|
||||
from app.domains.chat.api.snapshot_controller import list_chat_snapshots
|
||||
|
||||
sig = inspect.signature(list_chat_snapshots)
|
||||
param_names = list(sig.parameters.keys())
|
||||
|
|
@ -94,7 +90,7 @@ class TestSnapshotEndpointAuthRequirements:
|
|||
|
||||
def test_get_snapshot_requires_auth_dependency(self):
|
||||
"""GET /snapshots/{id} must include auth_must as a dependency."""
|
||||
from app.controller.chat.snapshot_controller import get_chat_snapshot
|
||||
from app.domains.chat.api.snapshot_controller import get_chat_snapshot
|
||||
|
||||
sig = inspect.signature(get_chat_snapshot)
|
||||
param_names = list(sig.parameters.keys())
|
||||
|
|
@ -102,7 +98,7 @@ class TestSnapshotEndpointAuthRequirements:
|
|||
|
||||
def test_create_snapshot_requires_auth_dependency(self):
|
||||
"""POST /snapshots must include auth_must as a dependency."""
|
||||
from app.controller.chat.snapshot_controller import create_chat_snapshot
|
||||
from app.domains.chat.api.snapshot_controller import create_chat_snapshot
|
||||
|
||||
sig = inspect.signature(create_chat_snapshot)
|
||||
param_names = list(sig.parameters.keys())
|
||||
|
|
@ -110,7 +106,7 @@ class TestSnapshotEndpointAuthRequirements:
|
|||
|
||||
def test_update_snapshot_requires_auth_dependency(self):
|
||||
"""PUT /snapshots/{id} must include auth_must as a dependency."""
|
||||
from app.controller.chat.snapshot_controller import update_chat_snapshot
|
||||
from app.domains.chat.api.snapshot_controller import update_chat_snapshot
|
||||
|
||||
sig = inspect.signature(update_chat_snapshot)
|
||||
param_names = list(sig.parameters.keys())
|
||||
|
|
@ -118,7 +114,7 @@ class TestSnapshotEndpointAuthRequirements:
|
|||
|
||||
def test_delete_snapshot_requires_auth_dependency(self):
|
||||
"""DELETE /snapshots/{id} must include auth_must as a dependency."""
|
||||
from app.controller.chat.snapshot_controller import delete_chat_snapshot
|
||||
from app.domains.chat.api.snapshot_controller import delete_chat_snapshot
|
||||
|
||||
sig = inspect.signature(delete_chat_snapshot)
|
||||
param_names = list(sig.parameters.keys())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue