Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

55 Zeilen
3.1KB

  1. $ErrorActionPreference = 'Stop'
  2. $projectRoot = Split-Path -Parent $PSScriptRoot
  3. $workPath = Join-Path $projectRoot ('temp\contact-flow-' + [guid]::NewGuid().ToString('N'))
  4. New-Item -ItemType Directory -Path $workPath -Force | Out-Null
  5. $databasePath = Join-Path $workPath 'test.mdb'
  6. $configPath = Join-Path $workPath 'test.ini'
  7. $csvPath = Join-Path $workPath 'contacts.csv'
  8. $pickupPath = Join-Path $workPath 'pickup'
  9. $scriptHost = Join-Path $env:SystemRoot 'SysWOW64\cscript.exe'
  10. $powerShellX86 = Join-Path $env:SystemRoot 'SysWOW64\WindowsPowerShell\v1.0\powershell.exe'
  11. try {
  12. $example = Get-Content -LiteralPath (Join-Path $projectRoot 'config.example.ini') -Raw
  13. $example.Replace('DB_PATH=data/MassMailer.mdb', ('DB_PATH=' + $databasePath)).Replace(
  14. 'SMTP_TEST_TO=', 'SMTP_TEST_TO=test@example.invalid') |
  15. Set-Content -LiteralPath $configPath -Encoding UTF8
  16. @'
  17. email,business_name,source_reference,acquired_at
  18. one@example.invalid,"Example, Inc.",https://example.invalid/one,2026-10-20
  19. two@example.invalid,Two,,
  20. ONE@example.invalid,Duplicate,https://example.invalid/one,
  21. blocked@example.invalid,Blocked,https://example.invalid/blocked,
  22. '@ | Set-Content -LiteralPath $csvPath -Encoding UTF8
  23. & $scriptHost //nologo (Join-Path $PSScriptRoot 'init-db.vbs') $configPath
  24. if ($LASTEXITCODE -ne 0) { throw 'MDB initialization failed' }
  25. & $scriptHost //nologo (Join-Path $PSScriptRoot 'launch.vbs') check $configPath
  26. if ($LASTEXITCODE -ne 0) { throw 'Startup preflight failed' }
  27. & $powerShellX86 -NoProfile -ExecutionPolicy Bypass -File (Join-Path $PSScriptRoot 'test-secret-store.ps1') -ConfigPath $configPath
  28. if ($LASTEXITCODE -ne 0) { throw 'Protected password test failed' }
  29. New-Item -ItemType Directory -Path $pickupPath | Out-Null
  30. & $powerShellX86 -NoProfile -ExecutionPolicy Bypass -File (Join-Path $PSScriptRoot 'test-smtp-message.ps1') -ConfigPath $configPath -PickupDirectory $pickupPath
  31. if ($LASTEXITCODE -ne 0) { throw 'Pickup MIME test failed' }
  32. $messages = @(Get-ChildItem -LiteralPath $pickupPath -Filter '*.eml' -File)
  33. if ($messages.Count -ne 1) { throw 'Pickup MIME test did not create one message' }
  34. $mime = Get-Content -LiteralPath $messages[0].FullName -Raw
  35. if ($mime -notmatch 'multipart/related' -or $mime -notmatch 'Content-ID:\s*<massmailer-test-image>') {
  36. throw 'Pickup MIME is missing a related inline image'
  37. }
  38. Write-Output 'HTML and inline-image MIME pickup test passed'
  39. & $scriptHost //nologo //E:JScript (Join-Path $PSScriptRoot 'test-contact-flow.js') $databasePath $csvPath
  40. if ($LASTEXITCODE -ne 0) { throw 'Contact flow test failed' }
  41. }
  42. finally {
  43. if (Test-Path -LiteralPath $pickupPath) {
  44. Get-ChildItem -LiteralPath $pickupPath -File | ForEach-Object { Remove-Item -LiteralPath $_.FullName -Force }
  45. Remove-Item -LiteralPath $pickupPath -Force
  46. }
  47. foreach ($fileName in @('test.ini', 'contacts.csv', 'test.mdb', 'test.ldb')) {
  48. $filePath = Join-Path $workPath $fileName
  49. if (Test-Path -LiteralPath $filePath) { Remove-Item -LiteralPath $filePath -Force }
  50. }
  51. if (Test-Path -LiteralPath $workPath) { Remove-Item -LiteralPath $workPath -Force }
  52. }

Powered by TurnKey Linux.