param([string]$SecretsFile = (Join-Path $PSScriptRoot 'secrets.psd1')) . (Join-Path $PSScriptRoot 'common.ps1') $settings = Read-LocalSettings $SecretsFile $origin = "http://127.0.0.1:$($settings.ServerPort)" $health = Invoke-RestMethod -Uri "$origin/actuator/health" -TimeoutSec 10 if ($health.status -ne 'UP') { throw 'Health check is not UP.' } $docs = Invoke-WebRequest -Uri "$origin/doc.html" -UseBasicParsing -TimeoutSec 10 if ($docs.StatusCode -ne 200) { throw 'API documentation is unavailable.' } $login = Invoke-RestMethod -Uri "$origin/admin-api/system/auth/login" -Method Post -Headers @{ 'tenant-id' = '1' } ` -ContentType 'application/json' -Body '{"username":"admin","password":"admin123"}' -TimeoutSec 15 if ($login.code -ne 0) { throw "Seed administrator login failed: $($login.msg)" } $headers = @{ 'tenant-id' = '1'; Authorization = ('Bearer ' + $login.data.accessToken) } try { $permission = Invoke-RestMethod -Uri "$origin/admin-api/system/auth/get-permission-info" -Headers $headers -TimeoutSec 15 if ($permission.code -ne 0) { throw "Permission API failed: $($permission.msg)" } $users = Invoke-RestMethod -Uri "$origin/admin-api/system/user/page?pageNo=1&pageSize=10" -Headers $headers -TimeoutSec 15 if ($users.code -ne 0) { throw "User list API failed: $($users.msg)" } Write-Output "Health UP; API docs HTTP 200; login and permission APIs passed; user list total=$($users.data.total)." } finally { $logout = Invoke-RestMethod -Uri "$origin/admin-api/system/auth/logout" -Method Post -Headers $headers -TimeoutSec 15 if ($logout.code -ne 0) { throw 'Logout failed.' } }