Remove all authentication (login, sessions, bcrypt, itsdangerous) since the app runs on a private homelab LAN. Replace with a profile picker landing page and cookie-based profile selection (1-year expiry). - Add Alembic migration to drop password_hash/is_admin columns - Delete auth service, auth routes, login template, and auth tests - Rewrite app/utils/auth.py with NoProfileSelectedError and require_active_profile dependency - Add profile creation flow (GET/POST /profiles/create) - Rewrite home page as profile picker with card layout - Update all route files to use profile dependency instead of admin auth - Remove bcrypt and itsdangerous from requirements - Remove admin_username/admin_password from config - Update all tests for new profile-based access model Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
32 lines
840 B
Python
32 lines
840 B
Python
"""Shared test fixtures for the SneakySwole test suite."""
|
|
|
|
import os
|
|
from unittest.mock import patch
|
|
|
|
import pytest
|
|
from fastapi.testclient import TestClient
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def _set_test_env() -> None:
|
|
"""Ensure required env vars are set for all tests."""
|
|
with patch.dict(os.environ, {
|
|
"APP_ENV": "development",
|
|
"DATABASE_URL": "sqlite:///data/test_sneakyswole.db",
|
|
}, clear=False):
|
|
yield
|
|
|
|
|
|
@pytest.fixture
|
|
def client() -> TestClient:
|
|
"""Create a FastAPI TestClient for integration tests."""
|
|
from app.main import create_app
|
|
|
|
app = create_app()
|
|
return TestClient(app)
|
|
|
|
|
|
def set_profile_cookie(client: TestClient, profile_id: int) -> None:
|
|
"""Helper to set the active_profile_id cookie on a test client."""
|
|
client.cookies.set("active_profile_id", str(profile_id))
|