# SteamAPI Interface Verification Script # Verify all endpoints are responding $baseUrl = "http://127.0.0.1:5000" $results = @() function Test-Endpoint { param( [string]$Method, [string]$Path, [string]$Description, [object]$Body = $null ) $url = "$baseUrl$Path" try { $params = @{ Uri = $url Method = $Method ContentType = "application/json" TimeoutSec = 10 ErrorAction = "Stop" } if ($Body) { $params.Body = ($Body | ConvertTo-Json -Compress) } $response = Invoke-WebRequest @params $statusCode = [int]$response.StatusCode return @{ Path = $Path Method = $Method Description = $Description Status = "OK" StatusCode = $statusCode Message = "Endpoint is running" } } catch [System.Net.WebException] { $response = $_.Exception.Response if ($response -ne $null) { $statusCode = [int]$response.StatusCode # Any HTTP response means the endpoint is running return @{ Path = $Path Method = $Method Description = $Description Status = "OK" StatusCode = $statusCode Message = "Endpoint is running (HTTP $statusCode)" } } return @{ Path = $Path Method = $Method Description = $Description Status = "FAIL" StatusCode = 0 Message = "Endpoint not responding: Connection failed" } } catch { return @{ Path = $Path Method = $Method Description = $Description Status = "FAIL" StatusCode = 0 Message = "Endpoint not responding: $($_.Exception.Message)" } } } Write-Host "========================================" -ForegroundColor Cyan Write-Host " SteamAPI Interface Verification" -ForegroundColor Cyan Write-Host "========================================" -ForegroundColor Cyan Write-Host "" # Check if port 5000 is listening Write-Host "[1] Checking port 5000 status..." -ForegroundColor Yellow $portCheck = netstat -ano | Select-String ":5000.*LISTENING" if ($portCheck) { Write-Host " Port 5000 is LISTENING" -ForegroundColor Green } else { Write-Host " Port 5000 is NOT listening" -ForegroundColor Red exit 1 } Write-Host "" # Define all endpoints from Program.cs $endpoints = @( @{ Method = "POST" Path = "/login" Description = "Steam Login" Body = @{ Username = "test"; Password = "test"; MaFilePath = "test.json" } }, @{ Method = "POST" Path = "/wallet-balance" Description = "Wallet Balance Query" Body = @{ SteamLoginSecure = "" } }, @{ Method = "POST" Path = "/trade-confirmations/list" Description = "Trade Confirmations List" Body = @{ MaFilePath = "test.json"; Session = $null } }, @{ Method = "POST" Path = "/trade-confirmations/operate" Description = "Trade Confirmation Operate" Body = @{ MaFilePath = "test.json"; Session = $null; ConfirmationId = 0; Operation = "accept" } } ) Write-Host "[2] Testing all endpoints..." -ForegroundColor Yellow Write-Host "" $index = 1 foreach ($endpoint in $endpoints) { $result = Test-Endpoint -Method $endpoint.Method -Path $endpoint.Path -Description $endpoint.Description -Body $endpoint.Body $results += $result $statusIcon = if ($result.Status -eq "OK") { "[OK]" } else { "[FAIL]" } $statusColor = if ($result.Status -eq "OK") { "Green" } else { "Red" } Write-Host " $index. $($result.Method) $($result.Path)" -ForegroundColor White Write-Host " Description: $($result.Description)" -ForegroundColor Gray Write-Host " Status: $statusIcon $($result.StatusCode) - $($result.Message)" -ForegroundColor $statusColor Write-Host "" $index++ } # Summary Write-Host "========================================" -ForegroundColor Cyan Write-Host " Verification Result" -ForegroundColor Cyan Write-Host "========================================" -ForegroundColor Cyan $okCount = ($results | Where-Object { $_.Status -eq "OK" }).Count $failCount = ($results | Where-Object { $_.Status -eq "FAIL" }).Count Write-Host " Total endpoints: $($results.Count)" Write-Host " Passed: $okCount" -ForegroundColor Green if ($failCount -gt 0) { Write-Host " Failed: $failCount" -ForegroundColor Red } Write-Host "" if ($failCount -eq 0) { Write-Host "All endpoints are running successfully!" -ForegroundColor Green exit 0 } else { Write-Host "Some endpoints failed to respond!" -ForegroundColor Red exit 1 }