from __future__ import annotations


def _super_headers(client) -> dict[str, str]:
    login = client.post(
        "/api/v1/auth/login",
        json={"email": "admin@compton.example", "password": "Admin1234"},
    )
    assert login.status_code == 200
    return {"Authorization": f"Bearer {login.json()['access_token']}"}


def test_admin_create_user_rejects_weak_password(client):
    headers = _super_headers(client)
    response = client.post(
        "/api/v1/admin/users",
        headers=headers,
        json={
            "email": "weak-pass@example.com",
            "password": "password",
            "role": "user",
            "is_superuser": False,
            "status": "active",
        },
    )
    assert response.status_code == 422
