$ErrorActionPreference = 'Stop' $tokens = $null $errors = $null $ast = [System.Management.Automation.Language.Parser]::ParseFile( (Join-Path $PSScriptRoot 'configure-caddy.ps1'), [ref]$tokens, [ref]$errors) if ($errors.Count) { throw ($errors | Out-String) } $fn = $ast.Find({param($n) $n -is [System.Management.Automation.Language.FunctionDefinitionAst]}, $true) Invoke-Expression $fn.Extent.Text $good = '{"handle":[{"handler":"subroute","routes":[{"match":[{"path":["/"]}],"handle":[{"handler":"static_response"}]},{"handle":[{"handler":"static_response"}]}]}]}' | ConvertFrom-Json if (-not (Test-StaticFallback @($good))) { throw 'Static fallback rejected' } $good.handle[0].routes[1].handle[0].handler = 'authentication' if (Test-StaticFallback @($good)) { throw 'Authentication fallback accepted' } $good.handle[0].routes[1].handle[0].handler = 'reverse_proxy' if (Test-StaticFallback @($good)) { throw 'Proxy fallback accepted' } if (Test-StaticFallback @()) { throw 'Empty fallback accepted' } Write-Output 'PASS: syntax, nested static fallback, authentication/proxy/empty guards'