# backend/tests/test_crypto.py — C6 토큰 암복호화 왕복
from app.crypto import decrypt_token, encrypt_token


def test_roundtrip():
    tok = {"access_token": "AT", "refresh_token": "RT", "expires_at": 123456}
    enc = encrypt_token(tok)
    assert "AT" not in enc  # 평문 노출 금지
    assert decrypt_token(enc) == tok


def test_empty_and_corrupt_safe():
    assert decrypt_token("") == {}
    assert decrypt_token("not-a-valid-fernet-token") == {}  # 예외 누수 없이 {} 폴백
