""" TDD scaffold for Phase 7.3: ES256 algorithm upgrade, startup token rotation, and remember_me session TTL — all stubs xfail strict=True until promoted. """ import base64 import hashlib import json import time import uuid from datetime import datetime, timedelta, timezone import pytest import pytest_asyncio from cryptography.hazmat.primitives import serialization from cryptography.hazmat.primitives.asymmetric import ec @pytest.fixture(autouse=True) def es256_keys(monkeypatch): """Patch settings with a freshly generated P-256 key pair for each test.""" k = ec.generate_private_key(ec.SECP256R1()) priv = base64.b64encode( k.private_bytes( serialization.Encoding.PEM, serialization.PrivateFormat.PKCS8, serialization.NoEncryption(), ) ).decode() pub = base64.b64encode( k.public_key().public_bytes( serialization.Encoding.PEM, serialization.PublicFormat.SubjectPublicKeyInfo, ) ).decode() monkeypatch.setattr("config.settings.jwt_private_key", priv, raising=False) monkeypatch.setattr("config.settings.jwt_public_key", pub, raising=False) # ── ES256 algorithm stubs ───────────────────────────────────────────────────── @pytest.mark.xfail(strict=True, reason="ES256-01: not yet implemented") def test_access_token_uses_es256(): pytest.xfail("not yet implemented") @pytest.mark.xfail(strict=True, reason="ES256-02: not yet implemented") def test_hs256_token_rejected(): pytest.xfail("not yet implemented") @pytest.mark.xfail(strict=True, reason="ES256-03: not yet implemented") def test_reset_token_uses_es256(): pytest.xfail("not yet implemented") # ── Startup token rotation stubs ────────────────────────────────────────────── @pytest.mark.xfail(strict=True, reason="ES256-04: not yet implemented") @pytest.mark.asyncio async def test_startup_rotation_revokes_tokens(db_session): pytest.xfail("not yet implemented") @pytest.mark.xfail(strict=True, reason="ES256-05: not yet implemented") @pytest.mark.asyncio async def test_startup_rotation_idempotent(db_session): pytest.xfail("not yet implemented") # ── Remember-me TTL stubs ───────────────────────────────────────────────────── @pytest.mark.xfail(strict=True, reason="RM-01: not yet implemented") @pytest.mark.asyncio async def test_default_ttl_16_hours(async_client, db_session, auth_user): pytest.xfail("not yet implemented") @pytest.mark.xfail(strict=True, reason="RM-02: not yet implemented") @pytest.mark.asyncio async def test_remember_me_ttl_30_days(async_client, db_session, auth_user): pytest.xfail("not yet implemented") @pytest.mark.xfail(strict=True, reason="RM-03: not yet implemented") @pytest.mark.asyncio async def test_remember_me_cookie_max_age(async_client, auth_user): pytest.xfail("not yet implemented") # ── Config field stubs ──────────────────────────────────────────────────────── @pytest.mark.xfail(strict=True, reason="CFG-01: not yet implemented") def test_settings_has_jwt_keys(): pytest.xfail("not yet implemented")