feat: add local admin authentication
This commit is contained in:
@@ -1,10 +1,16 @@
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from cryptography.fernet import Fernet
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import Session, sessionmaker
|
||||
from sqlalchemy.pool import StaticPool
|
||||
|
||||
from app.config import Settings
|
||||
from app.db.models import Base
|
||||
from app.db.repositories import ActivityRepository, UserRepository
|
||||
from app.main import create_app
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -28,3 +34,16 @@ def user_repository(db_session: Session) -> UserRepository:
|
||||
@pytest.fixture
|
||||
def activity_repository(db_session: Session) -> ActivityRepository:
|
||||
return ActivityRepository(db_session)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client(tmp_path: Path) -> TestClient:
|
||||
settings = Settings(
|
||||
ADMIN_PASSWORD="admin-secret",
|
||||
SECRET_KEY="0123456789abcdef0123456789abcdef",
|
||||
CREDENTIAL_ENCRYPTION_KEY=Fernet.generate_key().decode("ascii"),
|
||||
DATA_DIR=str(tmp_path),
|
||||
DATABASE_URL=f"sqlite:///{tmp_path / 'app.db'}",
|
||||
SYNC_INTERVAL_MINUTES=5,
|
||||
)
|
||||
return TestClient(create_app(settings))
|
||||
|
||||
Reference in New Issue
Block a user