mirror of
https://github.com/fastapi-practices/fastapi_best_architecture.git
synced 2025-08-18 15:00:46 +08:00

* Update asynccasbin to casbin async api * remove pymysql dependency * update the test-user test to admin
22 lines
688 B
Python
22 lines
688 B
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
from starlette.testclient import TestClient
|
|
|
|
from backend.app.core.conf import settings
|
|
|
|
|
|
def test_login(client: TestClient) -> None:
|
|
data = {
|
|
'username': 'admin',
|
|
'password': '123456',
|
|
}
|
|
response = client.post(f'{settings.API_V1_STR}/auth/login', json=data)
|
|
assert response.status_code == 200
|
|
assert response.json()['data']['access_token_type'] == 'Bearer'
|
|
|
|
|
|
def test_logout(client: TestClient, token_headers: dict[str, str]) -> None:
|
|
response = client.post(f'{settings.API_V1_STR}/auth/logout', headers=token_headers)
|
|
assert response.status_code == 200
|
|
assert response.json()['code'] == 200
|