You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.8 KiB
41 lines
1.8 KiB
# 测试权限分配功能脚本 |
|
Write-Host "🧪 开始测试权限分配功能..." -ForegroundColor Yellow |
|
|
|
# 启动后端服务 |
|
Write-Host "🚀 启动后端服务..." -ForegroundColor Green |
|
Start-Process -FilePath "powershell" -ArgumentList "-ExecutionPolicy", "Bypass", "-File", "start-backend-only.ps1" -WindowStyle Minimized |
|
|
|
# 等待后端启动 |
|
Write-Host "⏳ 等待后端服务启动..." -ForegroundColor Cyan |
|
Start-Sleep -Seconds 10 |
|
|
|
# 测试权限API |
|
Write-Host "🔍 测试权限API..." -ForegroundColor Green |
|
|
|
# 测试获取权限列表 |
|
Write-Host "📋 测试获取权限列表..." -ForegroundColor Cyan |
|
try { |
|
$permissionsResponse = Invoke-RestMethod -Uri "http://localhost:8080/api/auth/permissions" -Method GET -Headers @{ |
|
"Authorization" = "Bearer YOUR_TOKEN_HERE" |
|
} -ErrorAction Stop |
|
Write-Host "✅ 权限列表API正常" -ForegroundColor Green |
|
Write-Host "权限数量: $($permissionsResponse.data.Count)" -ForegroundColor Cyan |
|
} catch { |
|
Write-Host "❌ 权限列表API测试失败: $($_.Exception.Message)" -ForegroundColor Red |
|
} |
|
|
|
# 测试获取角色列表 |
|
Write-Host "👥 测试获取角色列表..." -ForegroundColor Cyan |
|
try { |
|
$rolesResponse = Invoke-RestMethod -Uri "http://localhost:8080/api/auth/roles" -Method GET -Headers @{ |
|
"Authorization" = "Bearer YOUR_TOKEN_HERE" |
|
} -ErrorAction Stop |
|
Write-Host "✅ 角色列表API正常" -ForegroundColor Green |
|
Write-Host "角色数量: $($rolesResponse.data.data.Count)" -ForegroundColor Cyan |
|
} catch { |
|
Write-Host "❌ 角色列表API测试失败: $($_.Exception.Message)" -ForegroundColor Red |
|
} |
|
|
|
Write-Host "🎉 权限分配功能测试完成!" -ForegroundColor Green |
|
Write-Host "现在可以启动前端应用进行界面测试:" -ForegroundColor Cyan |
|
Write-Host "cd app && npm run dev:enhanced" -ForegroundColor Yellow
|
|
|