Files
张翔 b0f91d74f5 feat: 统一JWT密钥配置并修复签名验证问题
修复前端签名生成中bodyString硬编码问题
添加start-frontend.sh脚本启动前端服务
统一manage-app和gateway的JWT密钥配置
修复Repository扫描路径问题
更新测试配置和依赖
重构表名映射为sys_user和sys_role
完善用户实体类字段映射
添加集成测试配置和测试用例
2026-04-02 12:28:49 +08:00

73 lines
2.2 KiB
Python

#!/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)
context = browser.new_context()
page = context.new_page()
# 监听网络请求
api_requests = []
def handle_request(request):
if '/api/' in request.url:
headers = request.headers
api_requests.append({
'url': request.url,
'method': request.method,
'has_signature': 'X-Signature' in headers,
'has_timestamp': 'X-Timestamp' in headers,
'has_token': 'Authorization' in headers
})
print(f"\n请求: {request.method} {request.url}")
print(f" 签名头: {headers.get('X-Signature', 'None')[:30]}...")
print(f" 时间戳: {headers.get('X-Timestamp', 'None')}")
print(f" Token: {headers.get('Authorization', 'None')[:30]}...")
def handle_response(response):
if '/api/' in response.url:
print(f"\n响应: {response.status} {response.url}")
if response.status == 401:
print(f" ⚠️ 401错误!")
page.on('request', handle_request)
page.on('response', handle_response)
# 登录
print("登录...")
page.goto("http://localhost:3002/login")
page.wait_for_load_state("networkidle")
page.fill('input[placeholder="请输入用户名"]', 'admin')
page.fill('input[placeholder="请输入密码"]', 'admin123')
page.click('button:has-text("登录")')
# 等待Token
for i in range(10):
time.sleep(1)
token = page.evaluate("localStorage.getItem('token')")
if token:
break
print(f"\nToken: {token[:50]}...")
# 访问dashboard
print("\n\n访问Dashboard...")
page.goto("http://localhost:3002/dashboard")
page.wait_for_load_state("networkidle")
time.sleep(2)
# 访问用户管理
print("\n\n访问用户管理...")
page.goto("http://localhost:3002/users")
page.wait_for_load_state("networkidle")
time.sleep(2)
print(f"\n最终URL: {page.url}")
browser.close()