def test_login_success(client, admin_password):
    response = client.post(
        "/api/v1/auth/login",
        json={"username": "admin", "password": admin_password},
    )
    assert response.status_code == 200
    data = response.json()
    assert "access_token" in data
    assert "refresh_token" in data


def test_login_invalid_password(client, admin_password):
    response = client.post(
        "/api/v1/auth/login",
        json={"username": "admin", "password": f"{admin_password}_wrong"},
    )
    assert response.status_code == 401


def test_refresh_success(client, admin_tokens):
    response = client.post(
        "/api/v1/auth/refresh",
        json={"refresh_token": admin_tokens["refresh_token"]},
    )
    assert response.status_code == 200
    data = response.json()
    assert "access_token" in data
