38 lines
1.4 KiB
Python
38 lines
1.4 KiB
Python
from pathlib import Path
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[3]
|
|
SCRIPT = ROOT / "scripts/reboot-recovery/agent99-completion-callback-incident-id-migration.ps1"
|
|
|
|
|
|
def test_migration_requires_controlled_identity_and_supports_check_apply() -> None:
|
|
text = SCRIPT.read_text(encoding="utf-8")
|
|
|
|
assert '[ValidateSet("Check", "Apply")]' in text
|
|
assert "controlled_identity_invalid" in text
|
|
assert '"check_ready"' in text
|
|
assert '"migrated_verified"' in text
|
|
assert '"rolled_back_verified"' in text
|
|
|
|
|
|
def test_migration_uses_canonical_processed_identity_and_bounded_incident_id() -> None:
|
|
text = SCRIPT.read_text(encoding="utf-8")
|
|
|
|
assert 'processed.identity.incident_id' in text
|
|
assert '$canonicalIncidentId.Length -gt 30' in text
|
|
assert '"^INC-[A-Za-z0-9-]+$"' in text
|
|
assert 'rawExternalAlertIdLogged = $false' in text
|
|
assert 'priorAlertIdSha256 = Get-Sha256Text $priorAlertId' in text
|
|
|
|
|
|
def test_migration_is_atomic_backed_up_and_fail_closed() -> None:
|
|
text = SCRIPT.read_text(encoding="utf-8")
|
|
|
|
assert '[IO.File]::Replace($temporaryPath, $pendingPath, $replaceBackupPath, $true)' in text
|
|
assert "atomic_replace_backup_mismatch" in text
|
|
assert 'pending_payload_backup_mismatch' in text
|
|
assert 'pending_payload_changed_after_check' in text
|
|
assert 'immutable_receipt_exists' in text
|
|
assert 'rollbackVerified' in text
|
|
assert 'secretValueRead = $false' in text
|