Files
kite/backend/tests/test_auth_es256.py
T
curo1305 5c1a1f9504 test(07.3-01): add Wave 0 xfail scaffold — 9 ES256/RM/CFG stubs
- Create backend/tests/test_auth_es256.py with 9 xfail(strict=True) stubs
- Cover ES256-01..05 (access token, HS256 rejection, reset token, startup rotation)
- Cover RM-01..03 (16h default TTL, 30d remember_me TTL, cookie max_age)
- Cover CFG-01 satellite (jwt_private_key/jwt_public_key presence)
- Add es256_keys autouse fixture generating fresh P-256 keypair per test
- All 9 stubs collect and run as XFAIL; zero XPASS, zero ERROR
2026-06-06 16:49:58 +02:00

95 lines
3.4 KiB
Python

"""
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")