lab-install: the engine's machine id is the first 8 hex of api/state.machine_id (LabInstall-IdOf; the VM read api/state.machine empty); 11 of 11 agent-side cases on the VM
This commit is contained in:
parent
b3a8cb2e72
commit
780ea6c252
2 changed files with 12 additions and 2 deletions
|
|
@ -42,10 +42,18 @@ function LabInstall-Refusal($task, [string] $machineName, [string] $engineMachin
|
|||
return ''
|
||||
}
|
||||
|
||||
function LabInstall-IdOf($st) {
|
||||
# the engine's machine id as the fleet names it: the first 8 hex of api/state.machine_id (the per-install id; the intake header's
|
||||
# machine= and the registry's ae432dc7 / 1ccfe586 are that prefix); '' when the field is missing
|
||||
if ($null -eq $st) { return '' }
|
||||
$id = [string]$st.machine_id; if (-not $id) { $id = [string]$st.machine }
|
||||
if ($id -match '^[0-9a-f]{8}') { return $id.Substring(0, 8) }
|
||||
return ''
|
||||
}
|
||||
function LabInstall-EngineMachine() {
|
||||
$urlFile = Join-Path $env:LOCALAPPDATA 'igneum\app\app.url'
|
||||
if (-not (Test-Path $urlFile)) { return '' }
|
||||
try { $u = (Get-Content $urlFile -Raw).Trim(); $st = Invoke-RestMethod -Uri ($u + 'api/state') -TimeoutSec 5 -UseBasicParsing; return [string]$st.machine } catch { return '' }
|
||||
try { $u = (Get-Content $urlFile -Raw).Trim(); $st = Invoke-RestMethod -Uri ($u + 'api/state') -TimeoutSec 5 -UseBasicParsing; return (LabInstall-IdOf $st) } catch { return '' }
|
||||
}
|
||||
|
||||
function Lab-Install($task, [string] $dlBase) {
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ Expect 'refusal 3d: no engine answers (nothing installs blind)' (LabInstall-Refu
|
|||
Expect 'refusal: a public Setup name is not a lab Setup' (LabInstall-Refusal (Mk 'Igneum-Miner-Setup-2.0.3.exe' $sha 'ae432dc7' $sig) 'PC1' 'ae432dc7') 'not a lab Setup file name'
|
||||
$t = Mk 'Igneum-Miner-Lab-Setup-2.0.3.exe' $sha 'ae432dc7' $sig; $t.body = "# lab-install`nStart-Process evil.exe`n"
|
||||
Expect 'refusal: a body with a line that is not a pinned value (nothing of a body ever runs)' (LabInstall-Refusal $t 'PC1' 'ae432dc7') 'not the pinned form'
|
||||
if ((LabInstall-IdOf (@{ machine_id = 'ae432dc7b92c1817' })) -ne 'ae432dc7') { Write-Output 'FAIL id-of: not ae432dc7'; $fails++ } else { Write-Output 'ok id-of ae432dc7b92c1817 -> ae432dc7' }
|
||||
if ((LabInstall-IdOf (@{ version = '2.0.3' })) -ne '') { Write-Output 'FAIL id-of: a state without machine_id must read empty'; $fails++ } else { Write-Output 'ok id-of: no machine_id -> empty (refused later as no engine)' }
|
||||
if ($fails -gt 0) { Write-Output ('RESULT lab-install agent test: ' + $fails + ' FAIL'); exit 1 }
|
||||
Write-Output 'RESULT lab-install agent test: 9 of 9 as expected (1 acceptance, 8 refusals)'
|
||||
Write-Output 'RESULT lab-install agent test: 11 of 11 as expected (1 acceptance, 8 refusals, 2 id reads)'
|
||||
exit 0
|
||||
|
|
|
|||
Loading…
Reference in a new issue