Files
celery/tests/test_auth.py
gilesb 19e2277155 Track art-common master branch, add auth tests
Fix UserContext l2_server field not found error by tracking
master branch instead of pinned commit.

- Update art-common to track master branch
- Add tests for UserContext l2_server field

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 10:25:54 +00:00

43 lines
1.2 KiB
Python

"""
Tests for authentication service.
"""
import pytest
class TestUserContext:
"""Tests for UserContext dataclass."""
def test_user_context_accepts_l2_server(self) -> None:
"""
Regression test: UserContext must accept l2_server field.
Bug found 2026-01-12: auth_service.py passes l2_server to UserContext
but the art-common library was pinned to old version without this field.
"""
from artdag_common.middleware.auth import UserContext
# This should not raise TypeError
ctx = UserContext(
username="testuser",
actor_id="@testuser@example.com",
token="test-token",
l2_server="https://l2.example.com",
)
assert ctx.username == "testuser"
assert ctx.actor_id == "@testuser@example.com"
assert ctx.token == "test-token"
assert ctx.l2_server == "https://l2.example.com"
def test_user_context_l2_server_optional(self) -> None:
"""l2_server should be optional (default None)."""
from artdag_common.middleware.auth import UserContext
ctx = UserContext(
username="testuser",
actor_id="@testuser@example.com",
)
assert ctx.l2_server is None