[CmdletBinding()] param( [int]$WebPort = 8083, [int]$ApiPort = 8082 ) $ErrorActionPreference = "Stop" $apiBase = "http://127.0.0.1:$ApiPort/api/v1" $webBase = "http://127.0.0.1:$WebPort" $login = Invoke-RestMethod -Method Post -Uri "$apiBase/auth/login" -ContentType "application/json" -Body (@{ username = "admin" password = "mock-admin-secret" } | ConvertTo-Json) $headers = @{ Authorization = "Bearer $($login.session_token)" } $status = Invoke-RestMethod -Uri "$apiBase/system/status" -Headers $headers $network = Invoke-RestMethod -Uri "$apiBase/network" -Headers $headers $ports = Invoke-RestMethod -Uri "$apiBase/ports?limit=48" -Headers $headers $webSession = New-Object Microsoft.PowerShell.Commands.WebRequestSession $loginResponse = Invoke-WebRequest -UseBasicParsing -Method Post -Uri "$webBase/login" -WebSession $webSession -Body @{ username = "admin" password = "mock-admin-secret" } $proxyStatus = Invoke-RestMethod -Uri "$webBase/api/v1/system/status" -WebSession $webSession if ($ports.Count -ne 48) { throw "Expected 48 ports but received $($ports.Count)." } if ($proxyStatus.model -ne $status.model) { throw "The frontend proxy response does not match the backend response." } Write-Host "PASS backend login: $($login.actor)" Write-Host "PASS system model: $($status.model)" Write-Host "PASS network interfaces: $($network.interfaces.Count)" Write-Host "PASS serial ports: $($ports.Count)" Write-Host "PASS web login/proxy: HTTP $($loginResponse.StatusCode)"