Files
novalon-manage-system/api_integration_tests/debug_auth.py
T
张翔 c50ccd258f feat: 重构测试框架并优化代码结构
refactor(tests): 将e2e_tests迁移到tests_suite和api_integration_tests
style: 为Java类添加文档注释
docs: 更新.gitignore和配置文件
test: 添加性能测试和Playwright测试脚本
chore: 清理旧测试文件和配置
2026-03-14 13:49:39 +08:00

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())