| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- # Simulate all wired profile patch sources and verify event + read-back
- param(
- [string]$ApiBase = "http://127.0.0.1:8006",
- [int]$CompanyId = 338,
- [int]$TenantId = 33,
- [string]$OpsSecret = "lobster-dev-ops"
- )
- $ErrorActionPreference = "Stop"
- try {
- [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
- $OutputEncoding = [System.Text.Encoding]::UTF8
- } catch { }
- $utf8NoBom = New-Object System.Text.UTF8Encoding $false
- $reportDir = Join-Path $PSScriptRoot "reports"
- if (-not (Test-Path $reportDir)) { New-Item -ItemType Directory -Path $reportDir | Out-Null }
- $stamp = Get-Date -Format "yyyyMMdd-HHmmss"
- $reportFile = Join-Path $reportDir "lobster-profile-source-validation-$stamp.json"
- $headers = @{
- "Content-Type" = "application/json"
- "X-Lobster-Ops-Secret" = $OpsSecret
- }
- Write-Host "=== Profile Domain Source Hook Validation ===" -ForegroundColor Cyan
- Write-Host "ApiBase=$ApiBase CompanyId=$CompanyId TenantId=$TenantId"
- try {
- Invoke-RestMethod -Uri "$ApiBase/api/lobster/admin/phase2/verify/$CompanyId?tenantId=$TenantId" -Headers $headers -TimeoutSec 15 | Out-Null
- Write-Host "OK service reachable" -ForegroundColor Green
- } catch {
- Write-Host "FAIL service not reachable at $ApiBase" -ForegroundColor Red
- exit 1
- }
- $uri = "$($ApiBase.TrimEnd('/'))/api/lobster/admin/validation/profile-domain-sources/${CompanyId}?tenantId=${TenantId}"
- Write-Host "POST $uri"
- $resp = Invoke-RestMethod -Uri $uri -Method Post -Headers $headers -TimeoutSec 300
- $json = $resp | ConvertTo-Json -Depth 30
- [System.IO.File]::WriteAllText($reportFile, $json, $utf8NoBom)
- Write-Host "Report saved: $reportFile" -ForegroundColor Green
- if ($resp.sources) {
- foreach ($s in $resp.sources) {
- $label = $s.source
- if ($s.variant) { $label = "$label/$($s.variant)" }
- $color = if ($s.passed) { "Green" } else { "Red" }
- Write-Host " $label passed=$($s.passed) eventOk=$($s.eventOk) readBack=$($s.readBack)" -ForegroundColor $color
- if ($s.error) { Write-Host " error: $($s.error)" -ForegroundColor Red }
- }
- }
- Write-Host "passedCount=$($resp.passedCount)/$($resp.totalCount)" -ForegroundColor $(if ($resp.passed) { "Green" } else { "Yellow" })
- if ($resp.passed) {
- Write-Host "RESULT: PASS" -ForegroundColor Green
- exit 0
- }
- Write-Host "RESULT: FAIL - $($resp.message)" -ForegroundColor Red
- exit 1
|