refactor(web): elimina ruta moarta /cont/rar-creds

Ruta web POST /cont/rar-creds era cod mort: niciun template nu mai posta
catre ea (formularul live e /cont/rar-medii, US-008/PRD 5.20 cu sectiuni
explicite Testare+Productie si validare login per-env). Scria mereu in
slotul env-ului instantei — exact bug-ul semnalat la Issue A.

Elimina functia cont_rar_creds si cele doua teste care o exercitau
(test_set_creds_rar_din_sesiune, test_creds_alt_cont_neafectat). Actualizeaza
comentariul stale US-008 sa refere ruta reala /cont/rar-medii. Ruta API
/v1/conturi/rar-creds e separata si ramane neatinsa.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Claude Agent
2026-07-05 18:23:56 +00:00
parent 367739f5bf
commit 0a86e63213
2 changed files with 1 additions and 134 deletions

View File

@@ -6,7 +6,6 @@ dupa implementare trec (GREEN).
Rute testate:
- GET /_fragments/cont -> card "Contul meu"
- POST /cont/roteste-cheie -> cheie noua afisata o singura data
- POST /cont/rar-creds -> seteaza rar_creds_enc per cont din sesiune
"""
from __future__ import annotations
@@ -126,83 +125,6 @@ def test_roteste_cheie_afisata_o_data(client):
conn.close()
# ============================================================
# test_set_creds_rar_din_sesiune
# ============================================================
def test_set_creds_rar_din_sesiune(client):
"""User logat seteaza creds RAR: slotul per-env (US-013) != NULL, decriptabil."""
acct_id, user_id, _ = _create_account_user("creds@test.com")
_login(client, "creds@test.com", "parolasecreta10")
csrf = _get_csrf_from_fragment(client)
resp = client.post("/cont/rar-creds", data={
"csrf_token": csrf,
"rar_email": "user@rar.ro",
"rar_parola": "parolaRAR123",
})
assert resp.status_code == 200
# Mesaj de succes in raspuns
assert "succes" in resp.text.lower() or "salvat" in resp.text.lower() or "configurat" in resp.text.lower(), \
f"Mesaj de succes lipsa: {resp.text[:500]}"
# Verifica in DB: slotul per-env setat si decriptabil (US-013: rar_creds_enc legacy dropata)
from app.db import get_connection
from app.crypto import decrypt_creds
conn = get_connection()
try:
row = conn.execute(
"SELECT rar_creds_test_enc, rar_creds_prod_enc FROM accounts WHERE id=?", (acct_id,)
).fetchone()
assert row is not None
enc = row["rar_creds_test_enc"] or row["rar_creds_prod_enc"]
assert enc is not None, "Cel putin un slot per-env trebuia setat (US-013)"
creds = decrypt_creds(enc)
assert creds is not None
assert creds.get("email") == "user@rar.ro"
assert creds.get("password") == "parolaRAR123"
finally:
conn.close()
# ============================================================
# test_creds_alt_cont_neafectat
# ============================================================
def test_creds_alt_cont_neafectat(client):
"""User A seteaza creds -> contul B ramane fara creds (sloturi per-env NULL, US-013)."""
acct_a, user_a, _ = _create_account_user("userA@test.com")
acct_b, user_b, _ = _create_account_user("userB@test.com")
# Logam user A si setam creds
_login(client, "userA@test.com", "parolasecreta10")
csrf = _get_csrf_from_fragment(client)
resp = client.post("/cont/rar-creds", data={
"csrf_token": csrf,
"rar_email": "a@rar.ro",
"rar_parola": "parolaA123",
})
assert resp.status_code == 200
# Verifica: contul A are creds in slotul per-env, contul B ramane NULL (US-013)
from app.db import get_connection
conn = get_connection()
try:
row_a = conn.execute(
"SELECT rar_creds_test_enc, rar_creds_prod_enc FROM accounts WHERE id=?", (acct_a,)
).fetchone()
row_b = conn.execute(
"SELECT rar_creds_test_enc, rar_creds_prod_enc FROM accounts WHERE id=?", (acct_b,)
).fetchone()
enc_a = row_a["rar_creds_test_enc"] or row_a["rar_creds_prod_enc"]
enc_b = row_b["rar_creds_test_enc"] or row_b["rar_creds_prod_enc"]
assert enc_a is not None, "Contul A trebuia sa aiba creds in slotul per-env"
assert enc_b is None, "Contul B nu trebuia atins"
finally:
conn.close()
# ============================================================
# test_roteste_fara_csrf_403_in_prod
# ============================================================