You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
103 lines
4.5 KiB
PowerShell
103 lines
4.5 KiB
PowerShell
param(
|
|
[string]$BaseUrl = "http://127.0.0.1:8999"
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
function Invoke-Api {
|
|
param(
|
|
[Parameter(Mandatory = $true)][string]$Path,
|
|
[string]$Method = "GET",
|
|
$Body = $null
|
|
)
|
|
|
|
$uri = "$BaseUrl$Path"
|
|
try {
|
|
if ($null -eq $Body) {
|
|
Invoke-RestMethod -Uri $uri -Method $Method -TimeoutSec 12
|
|
} else {
|
|
$json = $Body | ConvertTo-Json -Depth 8
|
|
Invoke-RestMethod -Uri $uri -Method $Method -TimeoutSec 12 -ContentType "application/json" -Body $json
|
|
}
|
|
} catch {
|
|
Write-Host "[FAIL] $Method $uri" -ForegroundColor Red
|
|
throw
|
|
}
|
|
}
|
|
|
|
function Assert-Data {
|
|
param(
|
|
[Parameter(Mandatory = $true)]$Response,
|
|
[Parameter(Mandatory = $true)][string]$Name
|
|
)
|
|
|
|
if ($null -eq $Response -or $Response.code -ne 200 -or $null -eq $Response.data) {
|
|
throw "$Name returned an invalid response"
|
|
}
|
|
$Response.data
|
|
}
|
|
|
|
Write-Host "Smart claim business-flow smoke test" -ForegroundColor Cyan
|
|
Write-Host "Base URL: $BaseUrl"
|
|
|
|
$homeConfig = Assert-Data (Invoke-Api "/api/home/config") "home config"
|
|
$orders = (Assert-Data (Invoke-Api "/api/order/list") "order list").records
|
|
$order = $orders | Where-Object { $_.orderId -eq "ORD20260608001" } | Select-Object -First 1
|
|
if ($null -eq $order) { throw "Demo order ORD20260608001 not found" }
|
|
|
|
$reports = Assert-Data (Invoke-Api "/api/rider/claim/list") "rider reports"
|
|
$case = $reports | Where-Object { $_.caseNo -eq "CASE20260608001" } | Select-Object -First 1
|
|
if ($null -eq $case) { throw "Demo case CASE20260608001 not found" }
|
|
|
|
$diagnoses = Assert-Data (Invoke-Api "/api/hospital/diagnosis/list") "hospital diagnoses"
|
|
$diagnosis = $diagnoses | Where-Object { $_.diagnosisNo -eq "DIAG20260608001" } | Select-Object -First 1
|
|
if ($null -eq $diagnosis) { throw "Demo diagnosis DIAG20260608001 not found" }
|
|
|
|
$hospitalKeyPair = Assert-Data (Invoke-Api "/api/hospital/node/generateKeyPair?algorithm=SM2") "hospital key pair"
|
|
if ([string]::IsNullOrWhiteSpace($hospitalKeyPair.publicKey) -or [string]::IsNullOrWhiteSpace($hospitalKeyPair.privateKey)) {
|
|
throw "Hospital key pair endpoint did not return publicKey/privateKey"
|
|
}
|
|
|
|
$policy = (Assert-Data (Invoke-Api "/api/insurance/policy/list") "insurance policies") |
|
|
Where-Object { $_.policyNo -eq "POL20260608001" } |
|
|
Select-Object -First 1
|
|
if ($null -eq $policy) { throw "Demo policy POL20260608001 not found" }
|
|
|
|
$damage = Assert-Data (Invoke-Api "/api/insurance/damage/detail/CASE20260608001") "damage detail"
|
|
$calculation = Assert-Data (Invoke-Api "/api/insurance/calculation/preview/CASE20260608001" "POST") "calculation preview"
|
|
$closeCase = Assert-Data (Invoke-Api "/api/insurance/close/form/CASE20260608001") "close form"
|
|
$conditions = Assert-Data (Invoke-Api "/api/insurance/close/conditions/CASE20260608001") "close conditions"
|
|
$payment = Assert-Data (Invoke-Api "/api/bank/payment/detail/CASE20260608001") "payment detail"
|
|
$trace = Assert-Data (Invoke-Api "/api/user/npc-admin/trace" "POST" @{ keyword = "CASE20260608001" }) "npc trace"
|
|
if (($trace | Measure-Object).Count -lt 10) {
|
|
throw "NPC trace should include at least 10 business-chain events"
|
|
}
|
|
$traceActions = $trace | ForEach-Object { $_.blockData }
|
|
foreach ($requiredAction in @("NODE_ON_CHAIN", "AUTO_INSURANCE", "ARCHIVE_RECORD", "CLAIM_REPORT", "MEDICAL_CHAIN", "DAMAGE_ASSESS", "CLAIM_CALCULATION", "RIDER_CONFIRM", "CLOSE_CASE", "BANK_PAYMENT")) {
|
|
if (($traceActions | Where-Object { $_ -like "*$requiredAction*" } | Measure-Object).Count -eq 0) {
|
|
throw "NPC trace missing action code: $requiredAction"
|
|
}
|
|
}
|
|
|
|
$summary = [ordered]@{
|
|
roleEntries = $homeConfig.entries.Count
|
|
hospitalKeyAlgorithm = $hospitalKeyPair.algorithm
|
|
orderId = $order.orderId
|
|
policyNo = $policy.policyNo
|
|
caseNo = $case.caseNo
|
|
diagnosisNo = $diagnosis.diagnosisNo
|
|
damageStatus = $damage.damageStatus
|
|
calculationStatus = $calculation.calculationStatus
|
|
totalClaimAmount = $calculation.totalClaimAmount
|
|
closeStatus = $closeCase.closeReviewStatus
|
|
closeConditionsPassed = (($conditions | Where-Object { $_.passed -eq $true }).Count)
|
|
paymentStatus = $payment.paymentStatus
|
|
paymentAmount = $payment.paymentAmount
|
|
traceEvents = ($trace | Measure-Object).Count
|
|
}
|
|
|
|
Write-Host "`n[PASS] Business-flow smoke test passed" -ForegroundColor Green
|
|
$summary.GetEnumerator() | ForEach-Object {
|
|
Write-Host ("{0}: {1}" -f $_.Key, $_.Value)
|
|
}
|