Skip to content

Commit e7520b5

Browse files
kwonkwonnclaude
andcommitted
test: Add legacy auth handlers and regression tests
- Add legacy/ directory with preserved function-based auth handlers - Add test_regression.py comparing legacy vs new handler responses - Ensure backwards compatibility during migration period Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 42f37cc commit e7520b5

File tree

5 files changed

+1605
-1
lines changed

5 files changed

+1605
-1
lines changed

changes/7865.enhance.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Migration of `manager/api/auth` into pydantic model. which include DTO, test, and Handler pattern.

src/ai/backend/manager/api/auth/__init__.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@
99

1010
from __future__ import annotations
1111

12+
from typing import Any
13+
14+
from aiohttp import web
15+
1216
from .decorators import (
1317
admin_required,
1418
auth_required,
1519
auth_required_for_method,
1620
superadmin_required,
1721
)
18-
from .handler import create_app
1922
from .middleware import auth_middleware
2023
from .utils import (
2124
_extract_auth_params,
@@ -24,6 +27,25 @@
2427
validate_ip,
2528
)
2629

30+
31+
def create_app(
32+
default_cors_options: Any,
33+
) -> tuple[web.Application, list[Any]]:
34+
"""Create aiohttp application for auth API endpoints.
35+
36+
Note: This wrapper defers handler import to avoid circular imports:
37+
dto.context -> services.processors -> repositories.repositories
38+
-> repositories.session.repository -> api.session -> api.auth/__init__
39+
-> api.auth/handler -> dto.context (circular!)
40+
41+
Root cause: repositories.session.repository imports api.session.find_dependency_sessions
42+
TODO: Move find_dependency_sessions to repository layer, then remove this wrapper.
43+
"""
44+
from .handler import create_app as _create_app
45+
46+
return _create_app(default_cors_options)
47+
48+
2749
__all__ = (
2850
# Middleware
2951
"auth_middleware",
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""
2+
Legacy API handlers.
3+
4+
This module contains old function-based handlers preserved for regression testing.
5+
These handlers should NOT be used in production - use the new class-based handlers instead.
6+
7+
Contents:
8+
- auth: Legacy auth handlers (replaced by api/auth/ package)
9+
"""
10+
11+
from __future__ import annotations
12+
13+
from . import auth
14+
15+
__all__ = ("auth",)

0 commit comments

Comments
 (0)