iOSBuildServer/tests/test_api_auth.py

21 lines
652 B
Python

"""认证接口测试"""
def test_login_success(client):
resp = client.post("/api/auth/login", json={"username": "admin", "password": "admin123"})
assert resp.status_code == 200
data = resp.json()
assert isinstance(data["token"], str)
assert data["token"]
assert data["is_admin"] is True
def test_login_wrong_password(client):
resp = client.post("/api/auth/login", json={"username": "admin", "password": "wrong"})
assert resp.status_code == 401
def test_login_wrong_username(client):
resp = client.post("/api/auth/login", json={"username": "nobody", "password": "admin123"})
assert resp.status_code == 401