Files
novalon-manage-system/e2e_tests/debug_auth.py
T

42 lines
1.4 KiB
Python

"""Debug script to test authentication"""
import asyncio
from httpx import AsyncClient
BASE_URL = "http://localhost:8080"
async def main():
async with AsyncClient(base_url=BASE_URL, timeout=30) as client:
# Test login
login_response = await client.post(
"/api/auth/login",
json={"username": "admin", "password": "admin123"}
)
print(f"Login status: {login_response.status_code}")
print(f"Login response: {login_response.json()}")
token = login_response.json().get("token")
print(f"Token: {token}")
# Test with token
headers = {"Authorization": f"Bearer {token}"}
# Test dict API
dict_response = await client.get("/api/dict/types", headers=headers)
print(f"Dict types status: {dict_response.status_code}")
# Test create dict
import time
timestamp = int(time.time() * 1000)
create_data = {
"dictName": f"测试字典_{timestamp}",
"dictType": f"test_{timestamp}",
"status": "0"
}
create_response = await client.post("/api/dict/types", json=create_data, headers=headers)
print(f"Create dict status: {create_response.status_code}")
print(f"Create dict response: {create_response.text}")
if __name__ == "__main__":
asyncio.run(main())