test(e2e): update e2e tests and auth tokens

- Update E2E test files with latest authentication tokens
- Improve test stability and error handling
- Update pytest configuration
- Enhance gateway direct test with settings integration
This commit is contained in:
张翔
2026-04-23 16:35:57 +08:00
parent f590c40c21
commit 0d0b4decc3
14 changed files with 1327 additions and 151 deletions
@@ -5,15 +5,16 @@
import requests
import time
from config.settings import settings
# 先登录获取Token
login_data = {
"username": "admin",
"password": "admin123"
"username": settings.TEST_USERNAME,
"password": settings.TEST_PASSWORD
}
print("1. 登录...")
response = requests.post("http://localhost:8080/api/auth/login", json=login_data)
response = requests.post(f"{settings.API_BASE_URL}/api/auth/login", json=login_data)
print(f"状态码: {response.status_code}")
print(f"响应: {response.text[:200]}...")
@@ -27,12 +28,12 @@ if response.status_code == 200:
"Authorization": f"Bearer {token}"
}
response2 = requests.get("http://localhost:8080/api/users/page?page=0&size=10", headers=headers)
response2 = requests.get(f"{settings.API_BASE_URL}/api/users/page?page=0&size=10", headers=headers)
print(f"状态码: {response2.status_code}")
print(f"响应: {response2.text[:200]}...")
# 测试用户统计API
print("\n3. 测试用户统计API...")
response3 = requests.get("http://localhost:8080/api/users/count", headers=headers)
response3 = requests.get(f"{settings.API_BASE_URL}/api/users/count", headers=headers)
print(f"状态码: {response3.status_code}")
print(f"响应: {response3.text[:200]}...")