- 修复登录控制器HTTP状态码问题,现在根据业务结果返回正确状态码 - 调整注册接口限流配置,从3次/5分钟放宽至10次/5分钟(开发环境) - 新增清除限流记录的调试接口,便于开发测试 - 更新API文档,反映状态码修复和限流调整 - 添加测试脚本验证修复效果 主要修复: - 业务失败时返回400/401而非200/201状态码 - 注册、登录、GitHub OAuth等接口现在正确处理错误状态码 - 限流配置更适合开发环境测试需求
29 lines
1.2 KiB
PowerShell
29 lines
1.2 KiB
PowerShell
# Test throttle functionality
|
|
$baseUrl = "http://localhost:3000"
|
|
|
|
Write-Host "Testing throttle functionality..." -ForegroundColor Green
|
|
|
|
# Test: Try to register (should work now with increased limit)
|
|
Write-Host "`nTesting register with increased throttle limit..." -ForegroundColor Yellow
|
|
$registerData = @{
|
|
username = "testuser_throttle"
|
|
password = "password123"
|
|
nickname = "Test User Throttle"
|
|
} | ConvertTo-Json
|
|
|
|
try {
|
|
$response = Invoke-RestMethod -Uri "$baseUrl/auth/register" -Method POST -Body $registerData -ContentType "application/json" -ErrorAction Stop
|
|
Write-Host "Status: Success (201)" -ForegroundColor Green
|
|
Write-Host "Response: $($response.message)" -ForegroundColor Green
|
|
} catch {
|
|
$statusCode = $_.Exception.Response.StatusCode.value__
|
|
Write-Host "Status Code: $statusCode" -ForegroundColor $(if ($statusCode -eq 429) { "Yellow" } else { "Red" })
|
|
|
|
if ($_.Exception.Response) {
|
|
$reader = New-Object System.IO.StreamReader($_.Exception.Response.GetResponseStream())
|
|
$responseBody = $reader.ReadToEnd()
|
|
Write-Host "Response: $responseBody" -ForegroundColor Gray
|
|
}
|
|
}
|
|
|
|
Write-Host "`nTest completed!" -ForegroundColor Green |