Files
kite/backend/tests/test_task1_models_config.py
T
curo1305 99f55825aa test(07.3-01): Wave 0 Nyquist scaffold — 9 xfail stubs for ES256 + remember_me
- Create test_auth_es256.py with 9 xfail(strict=True) stubs: ES256-01..05, RM-01..03, CFG-01
- Add es256_keys(autouse) fixture using cryptography P-256 keygen + monkeypatch with raising=False
- Extend test_settings_has_jwt_config to assert refresh_token_expire_hours==16 + jwt key fields
2026-06-06 17:13:50 +02:00

76 lines
2.5 KiB
Python

"""
TDD tests for Task 1: BackupCode ORM model, password_must_change field, Settings extension.
These tests should FAIL before implementation (RED phase).
"""
import pytest
def test_backup_code_model_exists():
"""BackupCode ORM model must exist and have correct tablename + columns."""
from db.models import BackupCode
assert BackupCode.__tablename__ == "backup_codes"
assert hasattr(BackupCode, "id")
assert hasattr(BackupCode, "user_id")
assert hasattr(BackupCode, "code_hash")
assert hasattr(BackupCode, "used_at")
def test_user_has_password_must_change():
"""User model must have password_must_change column."""
from db.models import User
assert hasattr(User, "password_must_change")
def test_settings_has_jwt_config():
"""Settings must have access_token_expire_minutes and refresh_token_expire_days."""
from config import settings
assert hasattr(settings, "access_token_expire_minutes")
assert settings.access_token_expire_minutes == 15
assert hasattr(settings, "refresh_token_expire_days")
assert settings.refresh_token_expire_days == 30
assert hasattr(settings, "refresh_token_expire_hours")
assert settings.refresh_token_expire_hours == 16
assert hasattr(settings, "jwt_private_key")
assert hasattr(settings, "jwt_public_key")
def test_settings_has_smtp_config():
"""Settings must have SMTP fields."""
from config import settings
assert hasattr(settings, "smtp_host")
assert hasattr(settings, "smtp_port")
assert hasattr(settings, "smtp_user")
assert hasattr(settings, "smtp_password")
assert hasattr(settings, "smtp_from")
def test_settings_has_admin_config():
"""Settings must have admin bootstrap fields."""
from config import settings
assert hasattr(settings, "admin_email")
assert hasattr(settings, "admin_password")
def test_settings_has_cors_origins():
"""Settings must have cors_origins as a list with default localhost."""
from config import settings
assert hasattr(settings, "cors_origins")
assert isinstance(settings.cors_origins, list)
assert "http://localhost:5173" in settings.cors_origins
def test_backup_code_table_in_schema(db_session):
"""backup_codes table must be created in the SQLite test schema."""
from db.models import BackupCode
import uuid
# Should not raise — table must exist
bc = BackupCode(
id=uuid.uuid4(),
user_id=uuid.uuid4(),
code_hash="testhash",
used_at=None,
)
db_session.add(bc)
# We don't commit here — just verify the model is valid