feat(api/web): 实现API请求签名验证功能并优化测试环境配置
refactor(db): 重构查询条件类到query目录下 test: 添加登录流程测试脚本和测试数据 chore: 添加crypto-js依赖用于签名验证 ci: 配置测试环境数据库和端口设置
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
检查登录API响应
|
||||
"""
|
||||
|
||||
from playwright.sync_api import sync_playwright
|
||||
import time
|
||||
|
||||
with sync_playwright() as p:
|
||||
browser = p.chromium.launch(headless=True)
|
||||
page = browser.new_page()
|
||||
|
||||
# 监听网络请求
|
||||
responses = []
|
||||
|
||||
def handle_response(response):
|
||||
if 'login' in response.url or 'auth' in response.url:
|
||||
responses.append({
|
||||
'url': response.url,
|
||||
'status': response.status,
|
||||
'body': response.text() if response.status != 204 else ''
|
||||
})
|
||||
|
||||
page.on('response', handle_response)
|
||||
|
||||
# 访问登录页面
|
||||
page.goto("http://localhost:3002/login")
|
||||
page.wait_for_load_state("networkidle")
|
||||
|
||||
print("尝试登录...")
|
||||
|
||||
# 填写表单
|
||||
page.fill('input[placeholder="请输入用户名"]', 'admin')
|
||||
page.fill('input[placeholder="请输入密码"]', 'Test@123')
|
||||
|
||||
# 点击登录
|
||||
page.click('button:has-text("登录")')
|
||||
|
||||
# 等待响应
|
||||
time.sleep(3)
|
||||
|
||||
print(f"\n登录后URL: {page.url}")
|
||||
|
||||
# 打印API响应
|
||||
print("\nAPI响应:")
|
||||
for resp in responses:
|
||||
print(f" URL: {resp['url']}")
|
||||
print(f" Status: {resp['status']}")
|
||||
if resp['body']:
|
||||
try:
|
||||
print(f" Body: {resp['body'][:500]}")
|
||||
except:
|
||||
pass
|
||||
|
||||
# 截图
|
||||
page.screenshot(path="/tmp/login_debug.png")
|
||||
|
||||
browser.close()
|
||||
Reference in New Issue
Block a user