45 lines
1.2 KiB
PowerShell
45 lines
1.2 KiB
PowerShell
# 测试新的日志格式
|
|
|
|
Write-Host "`n=== Testing New Log Format ===`n" -ForegroundColor Cyan
|
|
|
|
$baseUrl = "http://localhost:8080"
|
|
|
|
# 1. 测试健康检查
|
|
Write-Host "[1/4] Testing Health Check..." -ForegroundColor Yellow
|
|
Invoke-WebRequest -Uri "$baseUrl/health" -UseBasicParsing | Out-Null
|
|
Start-Sleep -Seconds 1
|
|
|
|
# 2. 测试登录
|
|
Write-Host "[2/4] Testing Login..." -ForegroundColor Yellow
|
|
$loginBody = @{
|
|
account = "test@example.com"
|
|
password = "Test@123"
|
|
} | ConvertTo-Json
|
|
|
|
Invoke-WebRequest -Uri "$baseUrl/api/v1/auth/login" `
|
|
-Method POST `
|
|
-Body $loginBody `
|
|
-ContentType "application/json" `
|
|
-UseBasicParsing | Out-Null
|
|
Start-Sleep -Seconds 1
|
|
|
|
# 3. 测试404
|
|
Write-Host "[3/4] Testing 404 Error..." -ForegroundColor Yellow
|
|
try {
|
|
Invoke-WebRequest -Uri "$baseUrl/api/v1/not-found" -UseBasicParsing | Out-Null
|
|
} catch {
|
|
# 忽略404错误
|
|
}
|
|
Start-Sleep -Seconds 1
|
|
|
|
# 4. 测试未授权
|
|
Write-Host "[4/4] Testing Unauthorized..." -ForegroundColor Yellow
|
|
try {
|
|
Invoke-WebRequest -Uri "$baseUrl/api/v1/user/profile" -UseBasicParsing | Out-Null
|
|
} catch {
|
|
# 忽略401错误
|
|
}
|
|
|
|
Write-Host "`n=== Test Complete! ===`n" -ForegroundColor Green
|
|
Write-Host "Check the server console for beautiful logs!" -ForegroundColor Cyan
|