28 lines
773 B
Python
28 lines
773 B
Python
def test_login_success(client):
|
|
response = client.post(
|
|
"/api/v1/auth/login",
|
|
json={"username": "admin", "password": "admin123"},
|
|
)
|
|
assert response.status_code == 200
|
|
data = response.json()
|
|
assert "access_token" in data
|
|
assert "refresh_token" in data
|
|
|
|
|
|
def test_login_invalid_password(client):
|
|
response = client.post(
|
|
"/api/v1/auth/login",
|
|
json={"username": "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
|