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

56 lines
1.7 KiB
Python

#!/usr/bin/env python3
"""
详细检查请求头
"""
from playwright.sync_api import sync_playwright
import time
import json
with sync_playwright() as p:
browser = p.chromium.launch(headless=True)
context = browser.new_context()
page = context.new_page()
# 监听网络请求
def handle_request(request):
if '/api/' in request.url and not request.url.endswith('.ts'):
headers = request.headers
print(f"\n{'='*80}")
print(f"请求: {request.method} {request.url}")
print(f"Headers:")
for key, value in headers.items():
if key.lower() in ['authorization', 'x-signature', 'x-timestamp', 'x-nonce']:
print(f" {key}: {value[:50]}...")
def handle_response(response):
if '/api/' in response.url and not response.url.endswith('.ts'):
print(f"响应: {response.status} {response.url}")
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:
print(f"\n登录成功,Token: {token[:50]}...")
break
# 访问dashboard
print("\n\n访问Dashboard...")
page.goto("http://localhost:3002/dashboard")
page.wait_for_load_state("networkidle")
time.sleep(3)
browser.close()