feat: 完成sys模块迁移,对齐PHP/Java框架
- 重构sys模块架构,严格按admin/api/core分层 - 对齐所有sys实体与数据库表结构 - 实现完整的adminapi控制器,匹配PHP/Java契约 - 修复依赖注入问题,确保服务正确注册 - 添加自动迁移工具和契约验证 - 完善多租户支持和审计功能 - 统一命名规范,与PHP业务逻辑保持一致
This commit is contained in:
102
wwjcloud/test/e2e/config-center-test.ps1
Normal file
102
wwjcloud/test/e2e/config-center-test.ps1
Normal file
@@ -0,0 +1,102 @@
|
||||
# 配置中心测试脚本
|
||||
|
||||
Write-Host "=== 配置中心功能测试 ===" -ForegroundColor Green
|
||||
|
||||
# 1. 登录获取令牌
|
||||
Write-Host "1. 登录获取令牌..." -ForegroundColor Yellow
|
||||
$loginBody = @{
|
||||
username = "admin"
|
||||
password = "123456"
|
||||
} | ConvertTo-Json
|
||||
|
||||
try {
|
||||
$loginResponse = Invoke-WebRequest -Uri "http://localhost:3000/adminapi/auth/login" -Method POST -ContentType "application/json" -Body $loginBody
|
||||
$loginData = $loginResponse.Content | ConvertFrom-Json
|
||||
|
||||
if ($loginData.token) {
|
||||
$token = $loginData.token
|
||||
Write-Host "✓ 登录成功,获取到令牌" -ForegroundColor Green
|
||||
|
||||
# 2. 测试系统配置接口
|
||||
Write-Host "`n2. 测试系统配置接口..." -ForegroundColor Yellow
|
||||
$headers = @{
|
||||
"Authorization" = "Bearer $token"
|
||||
"Content-Type" = "application/json"
|
||||
}
|
||||
|
||||
try {
|
||||
$systemConfigResponse = Invoke-WebRequest -Uri "http://localhost:3000/adminapi/config/system" -Method GET -Headers $headers
|
||||
$systemConfig = $systemConfigResponse.Content | ConvertFrom-Json
|
||||
Write-Host "✓ 系统配置获取成功" -ForegroundColor Green
|
||||
Write-Host "配置内容: $($systemConfig | ConvertTo-Json -Depth 2)" -ForegroundColor Cyan
|
||||
}
|
||||
catch {
|
||||
Write-Host "✗ 系统配置获取失败: $($_.Exception.Message)" -ForegroundColor Red
|
||||
}
|
||||
|
||||
# 3. 测试动态配置列表
|
||||
Write-Host "`n3. 测试动态配置列表..." -ForegroundColor Yellow
|
||||
try {
|
||||
$dynamicConfigResponse = Invoke-WebRequest -Uri "http://localhost:3000/adminapi/config/dynamic" -Method GET -Headers $headers
|
||||
$dynamicConfig = $dynamicConfigResponse.Content | ConvertFrom-Json
|
||||
Write-Host "✓ 动态配置列表获取成功" -ForegroundColor Green
|
||||
Write-Host "动态配置: $($dynamicConfig | ConvertTo-Json)" -ForegroundColor Cyan
|
||||
}
|
||||
catch {
|
||||
Write-Host "✗ 动态配置列表获取失败: $($_.Exception.Message)" -ForegroundColor Red
|
||||
}
|
||||
|
||||
# 4. 测试配置验证
|
||||
Write-Host "`n4. 测试配置验证..." -ForegroundColor Yellow
|
||||
try {
|
||||
$validateResponse = Invoke-WebRequest -Uri "http://localhost:3000/adminapi/config/validate" -Method GET -Headers $headers
|
||||
$validateResult = $validateResponse.Content | ConvertFrom-Json
|
||||
Write-Host "✓ 配置验证成功" -ForegroundColor Green
|
||||
Write-Host "验证结果: $($validateResult | ConvertTo-Json)" -ForegroundColor Cyan
|
||||
}
|
||||
catch {
|
||||
Write-Host "✗ 配置验证失败: $($_.Exception.Message)" -ForegroundColor Red
|
||||
}
|
||||
|
||||
# 5. 测试配置统计
|
||||
Write-Host "`n5. 测试配置统计..." -ForegroundColor Yellow
|
||||
try {
|
||||
$statsResponse = Invoke-WebRequest -Uri "http://localhost:3000/adminapi/config/stats" -Method GET -Headers $headers
|
||||
$stats = $statsResponse.Content | ConvertFrom-Json
|
||||
Write-Host "✓ 配置统计获取成功" -ForegroundColor Green
|
||||
Write-Host "统计信息: $($stats | ConvertTo-Json)" -ForegroundColor Cyan
|
||||
}
|
||||
catch {
|
||||
Write-Host "✗ 配置统计获取失败: $($_.Exception.Message)" -ForegroundColor Red
|
||||
}
|
||||
|
||||
# 6. 测试创建动态配置
|
||||
Write-Host "`n6. 测试创建动态配置..." -ForegroundColor Yellow
|
||||
$newConfigBody = @{
|
||||
key = "test.feature.flag"
|
||||
value = $true
|
||||
description = "测试功能开关"
|
||||
type = "boolean"
|
||||
category = "test"
|
||||
isPublic = $true
|
||||
} | ConvertTo-Json
|
||||
|
||||
try {
|
||||
$createResponse = Invoke-WebRequest -Uri "http://localhost:3000/adminapi/config/dynamic" -Method POST -Headers $headers -Body $newConfigBody
|
||||
$createResult = $createResponse.Content | ConvertFrom-Json
|
||||
Write-Host "✓ 动态配置创建成功" -ForegroundColor Green
|
||||
Write-Host "创建结果: $($createResult | ConvertTo-Json)" -ForegroundColor Cyan
|
||||
}
|
||||
catch {
|
||||
Write-Host "✗ 动态配置创建失败: $($_.Exception.Message)" -ForegroundColor Red
|
||||
}
|
||||
|
||||
} else {
|
||||
Write-Host "✗ 登录失败,未获取到令牌" -ForegroundColor Red
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Host "✗ 登录请求失败: $($_.Exception.Message)" -ForegroundColor Red
|
||||
}
|
||||
|
||||
Write-Host "`n=== 测试完成 ===" -ForegroundColor Green
|
||||
Reference in New Issue
Block a user