ProdLaunch

This commit is contained in:
2026-06-18 15:14:10 +02:00
parent d8f58640e5
commit 4c90a7c1a3
12 changed files with 1412 additions and 5 deletions
+100
View File
@@ -0,0 +1,100 @@
"""
Configurazione test E2E punta al server live.
Utilizzo:
# Dal server remoto o da locale con accesso alla porta 80:
BASE_URL=http://212.83.140.21 pytest tests/e2e/ -v --tb=short
# Oppure con pytest.ini/pyproject.toml configurato:
pytest tests/e2e/ -v -m e2e
"""
import os
import pytest
import httpx
# ── Configurazione ────────────────────────────────────────────────────────────
BASE_URL = os.environ.get("E2E_BASE_URL", "http://212.83.140.21")
API_URL = f"{BASE_URL}/api/v1"
# Credenziali admin del tenant demo (non super_admin)
ADMIN_EMAIL = os.environ.get("E2E_ADMIN_EMAIL", "admin@demo.pechub.it")
ADMIN_PASSWORD = os.environ.get("E2E_ADMIN_PASSWORD", "Demo@PEChub2026!")
# Credenziali casella PEC di test Aruba
PEC_EMAIL = "matteo.giustini@arubapec.it"
PEC_PASSWORD = "MadonnaPuttana1!"
PEC_IMAP_HOST = "imaps.pec.aruba.it"
PEC_IMAP_PORT = 993
PEC_SMTP_HOST = "smtps.pec.aruba.it"
PEC_SMTP_PORT = 465
# Destinatario per test invio (non PEC)
SEND_TEST_TO = "matteo1801@spidmail.it"
# Timeout per le richieste HTTP
REQUEST_TIMEOUT = 30.0
# ── Stato condiviso tra i test (simulazione sessione) ─────────────────────────
class E2EState:
"""Contiene lo stato accumulato durante l'esecuzione dei test E2E."""
access_token: str = ""
refresh_token: str = ""
mailbox_id: str = ""
message_id: str = ""
attachment_id: str = ""
send_job_id: str = ""
user_id: str = ""
label_id: str = ""
routing_rule_id: str = ""
fascicolo_id: str = ""
deadline_id: str = ""
notification_id: str = ""
state = E2EState()
# ── Fixtures ─────────────────────────────────────────────────────────────────
@pytest.fixture(scope="session")
def base_url() -> str:
return BASE_URL
@pytest.fixture(scope="session")
def api_url() -> str:
return API_URL
@pytest.fixture(scope="session")
def http() -> httpx.Client:
"""Client HTTP sincrono condiviso per tutta la sessione di test."""
with httpx.Client(
base_url=API_URL,
timeout=REQUEST_TIMEOUT,
follow_redirects=True,
) as client:
yield client
@pytest.fixture(scope="session")
def admin_token(http: httpx.Client) -> str:
"""Esegue il login e restituisce l'access token admin."""
resp = http.post("/auth/login", json={
"email": ADMIN_EMAIL,
"password": ADMIN_PASSWORD,
})
assert resp.status_code == 200, f"Login fallito: {resp.status_code} {resp.text}"
data = resp.json()
token = data["access_token"]
state.access_token = token
state.refresh_token = data.get("refresh_token", "")
return token
@pytest.fixture(scope="session")
def auth_headers(admin_token: str) -> dict:
"""Header Authorization per tutte le richieste autenticate."""
return {"Authorization": f"Bearer {admin_token}"}