Align the project baseline with the latest admin interface styling and layout structure while documenting setup and usage updates in README.
43 lines
1.4 KiB
Python
43 lines
1.4 KiB
Python
from tests.helpers import latest_token, register_and_verify
|
|
|
|
|
|
def test_health(client):
|
|
response = client.get("/api/v1/health")
|
|
assert response.status_code == 200
|
|
assert response.json()["status"] == "ok"
|
|
|
|
|
|
def test_register_and_verify_and_login(client):
|
|
register_response = client.post(
|
|
"/api/v1/auth/register",
|
|
json={"email": "user@example.com", "password": "Valid123"},
|
|
)
|
|
assert register_response.status_code == 200
|
|
assert "user_id" not in register_response.json()
|
|
|
|
duplicate = client.post(
|
|
"/api/v1/auth/register",
|
|
json={"email": "user@example.com", "password": "Valid123"},
|
|
)
|
|
assert duplicate.status_code == 200
|
|
assert "user_id" not in duplicate.json()
|
|
|
|
verify_response = client.post(
|
|
"/api/v1/auth/verify-email",
|
|
json={"token": latest_token("user@example.com", "verify_email")},
|
|
)
|
|
assert verify_response.status_code == 200
|
|
|
|
login_response = client.post(
|
|
"/api/v1/auth/login",
|
|
json={"email": "user@example.com", "password": "Valid123"},
|
|
)
|
|
assert login_response.status_code == 200
|
|
assert "access_token" in login_response.json()
|
|
|
|
|
|
def test_forgot_password_anti_enumeration(client):
|
|
response = client.post("/api/v1/auth/forgot-password", json={"email": "missing@example.com"})
|
|
assert response.status_code == 200
|
|
assert "If email is registered" in response.json()["message"]
|