Files
mono/artdag/l1/tests/test_auth.py
giles 1a74d811f7 Incorporate art-dag-mono repo into artdag/ subfolder
Merges full history from art-dag/mono.git into the monorepo
under the artdag/ directory. Contains: core (DAG engine),
l1 (Celery rendering server), l2 (ActivityPub registry),
common (shared templates/middleware), client (CLI), test (e2e).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

git-subtree-dir: artdag
git-subtree-mainline: 1a179de547
git-subtree-split: 4c2e716558
2026-02-27 09:07:23 +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