c50ccd258f
refactor(tests): 将e2e_tests迁移到tests_suite和api_integration_tests style: 为Java类添加文档注释 docs: 更新.gitignore和配置文件 test: 添加性能测试和Playwright测试脚本 chore: 清理旧测试文件和配置
22 lines
944 B
Python
22 lines
944 B
Python
import asyncio
|
|
from httpx import AsyncClient
|
|
|
|
async def test():
|
|
async with AsyncClient(base_url='http://localhost:8080') as client:
|
|
# 先登录获取token
|
|
login_resp = await client.post('/api/auth/login', json={'username': 'admin', 'password': 'admin123'})
|
|
print('Login status:', login_resp.status_code)
|
|
if login_resp.status_code == 200:
|
|
token = login_resp.json().get('token')
|
|
print('Token:', token[:20] if token else 'None')
|
|
|
|
# 测试分页API
|
|
headers = {'Authorization': f'Bearer {token}'}
|
|
page_resp = await client.get('/api/logs/login/page?page=0&size=10', headers=headers)
|
|
print('Page API status:', page_resp.status_code)
|
|
if page_resp.status_code != 200:
|
|
print('Error response:', page_resp.text[:500])
|
|
else:
|
|
print('Success:', page_resp.json())
|
|
|
|
asyncio.run(test()) |