Защита внутренних соединений и сервисных прав
This commit is contained in:
@@ -6,7 +6,11 @@ param(
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
Set-Location (Join-Path $PSScriptRoot '..')
|
||||
$projectRoot = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
|
||||
Set-Location $projectRoot
|
||||
if(-not (Test-Path (Join-Path $projectRoot 'compose.yaml'))) {
|
||||
throw "Run the repository copy of this script: $projectRoot does not contain compose.yaml."
|
||||
}
|
||||
$ca = (Resolve-Path 'secrets\pki\public-ca\ca.crt').Path
|
||||
|
||||
& "$PSScriptRoot\check-compose-hardening.ps1" -EnvFile $EnvFile
|
||||
@@ -30,8 +34,16 @@ with urllib.request.urlopen(sys.argv[1].rstrip('/') + '/health/ready', context=c
|
||||
'@
|
||||
$deadline = (Get-Date).AddSeconds($TimeoutSeconds)
|
||||
do {
|
||||
& $Python -c $probe $BaseUrl $ca 2>$null
|
||||
if($LASTEXITCODE -eq 0){ return }
|
||||
# Not ready yet is expected during recovery; do not turn it into a terminating error.
|
||||
$previous = $ErrorActionPreference
|
||||
$ErrorActionPreference = 'Continue'
|
||||
try {
|
||||
& $Python -c $probe $BaseUrl $ca 2>&1 | Out-Null
|
||||
$probeExit = $LASTEXITCODE
|
||||
} finally {
|
||||
$ErrorActionPreference = $previous
|
||||
}
|
||||
if($probeExit -eq 0){ return }
|
||||
Start-Sleep -Milliseconds 500
|
||||
} while((Get-Date) -lt $deadline)
|
||||
throw "HTTPS readiness did not recover within $TimeoutSeconds seconds"
|
||||
@@ -43,6 +55,13 @@ Run-Test @('tests/smoke.py','--base-url',$BaseUrl,'--ca-file',$ca)
|
||||
Run-Test @('tests/resilience.py','--mode','persistence','--action-script',(Resolve-Path 'scripts/restart.cmd').Path,'--base-url',$BaseUrl,'--ca-file',$ca)
|
||||
Run-Test @('tests/resilience.py','--mode','failover','--action-script',(Resolve-Path 'scripts/stop-one.cmd').Path,'--base-url',$BaseUrl,'--ca-file',$ca)
|
||||
|
||||
& docker compose --env-file $EnvFile up -d --no-deps --scale api=2 api
|
||||
if($LASTEXITCODE -ne 0){ throw 'Failed to restore the stopped API replica' }
|
||||
$previous = $ErrorActionPreference
|
||||
$ErrorActionPreference = 'Continue'
|
||||
try {
|
||||
& docker compose --env-file $EnvFile up -d --no-deps --scale api=2 api 2>&1 | Out-Null
|
||||
$restoreExit = $LASTEXITCODE
|
||||
} finally {
|
||||
$ErrorActionPreference = $previous
|
||||
}
|
||||
if($restoreExit -ne 0){ throw 'Failed to restore the stopped API replica' }
|
||||
Write-Host 'PASS: HTTPS smoke, persistence restart and one-replica failure completed with CA and hostname verification enabled.'
|
||||
|
||||
Reference in New Issue
Block a user