|
1 | 1 | # We import module BOSH.SSH to ensure that we get the Install-SSHD function it defines. Starting with |
2 | 2 | # OpenSSH 9.1, there is a conflicting install-sshd.ps1 script that takes precedence instead if you do |
3 | 3 | # not load the module. |
4 | | -Import-Module -Name BOSH.SSH |
5 | | -. ./AutomationHelpers.ps1 |
| 4 | +BeforeAll { |
| 5 | + Import-Module -Name BOSH.SSH |
| 6 | + . ./AutomationHelpers.ps1 |
| 7 | + |
| 8 | + function GenerateDepJson |
| 9 | + { |
| 10 | + param ([parameter(Mandatory = $true)] [string]$file1Sha, |
| 11 | + [parameter(Mandatory = $true)] [string]$file2Sha, |
| 12 | + [parameter(Mandatory = $true)] [string]$file3Sha |
| 13 | + ) |
| 14 | + |
| 15 | + return "{""file1.zip"":{""sha"":""$file1Sha"",""version"":""1.0""},""file2.zip"":{""sha"":""$file2Sha"",""version"":""1.0-alpha""},""file3.exe"":{""sha"":""$file3Sha"",""version"":""3.0""}}" |
| 16 | + } |
| 17 | + |
| 18 | + function CreateFakeOpenSSHZip |
| 19 | + { |
| 20 | + param([string]$dir, [string]$installScriptSpyStatus, [string]$fakeZipPath) |
| 21 | + |
| 22 | + mkdir "$dir\OpenSSH-Win64" |
| 23 | + $installSpyBehavior = "echo installed > $installScriptSpyStatus" |
| 24 | + echo $installSpyBehavior > "$dir\OpenSSH-Win64\install-sshd.ps1" |
| 25 | + echo "fake sshd" > "$dir\OpenSSH-Win64\sshd.exe" |
| 26 | + |
| 27 | + Compress-Archive -Force -Path "$dir\OpenSSH-Win64" -DestinationPath $fakeZipPath |
| 28 | + } |
| 29 | + |
| 30 | + function CreateFakeLGPOZip |
| 31 | + { |
| 32 | + param([string]$dir, [string]$fakeZipPath) |
| 33 | + |
| 34 | + New-Item -ItemType Directory "$dir\LGPO\LGPO_30" |
| 35 | + echo "fake lgpo" > "$dir\LGPO\LGPO_30\LGPO.exe" |
| 36 | + |
| 37 | + Compress-Archive -Force -Path "$dir\LGPO\*" -DestinationPath $fakeZipPath |
| 38 | + } |
| 39 | + |
| 40 | + function Get-WuCerts { } |
| 41 | + |
| 42 | +} |
6 | 43 |
|
7 | 44 | Describe "Setup" { |
8 | 45 | BeforeEach { |
@@ -233,7 +270,6 @@ Describe "InstallCFFeatures" { |
233 | 270 | } |
234 | 271 | } |
235 | 272 |
|
236 | | - |
237 | 273 | Describe "InstallCFCell" { |
238 | 274 | It "executes the Protect-CFCell powershell cmdlet" { |
239 | 275 | Mock Protect-CFCell { } |
@@ -517,18 +553,10 @@ Describe "Is-Special" { |
517 | 553 | } |
518 | 554 | } |
519 | 555 |
|
520 | | -function GenerateDepJson |
521 | | -{ |
522 | | - param ([parameter(Mandatory = $true)] [string]$file1Sha, |
523 | | - [parameter(Mandatory = $true)] [string]$file2Sha, |
524 | | - [parameter(Mandatory = $true)] [string]$file3Sha |
525 | | - ) |
526 | | - |
527 | | - return "{""file1.zip"":{""sha"":""$file1Sha"",""version"":""1.0""},""file2.zip"":{""sha"":""$file2Sha"",""version"":""1.0-alpha""},""file3.exe"":{""sha"":""$file3Sha"",""version"":""3.0""}}" |
528 | | -} |
529 | | - |
530 | 556 | Describe "Check-Dependencies" { |
531 | 557 | BeforeEach { |
| 558 | + Mock Check-Dependencies { } |
| 559 | + |
532 | 560 | Mock Write-Log { } |
533 | 561 |
|
534 | 562 | $file1Hash = @{ |
@@ -559,7 +587,6 @@ Describe "Check-Dependencies" { |
559 | 587 | Mock ConvertFrom-Json { throw "Invalid JSON primitive: bad-json-format" } -ParameterFilter { $InputObject -match "bad-json-format" } |
560 | 588 | } |
561 | 589 |
|
562 | | - |
563 | 590 | It "successfully checks all required files are available and have the correct SHAs" { |
564 | 591 | Mock Get-Content { GenerateDepJson "hashOne" "hashTwo" "hashThree" } |
565 | 592 |
|
@@ -822,28 +849,6 @@ Describe "Install-SecurityPoliciesAndRegistries" { |
822 | 849 |
|
823 | 850 | } |
824 | 851 |
|
825 | | -function CreateFakeOpenSSHZip |
826 | | -{ |
827 | | - param([string]$dir, [string]$installScriptSpyStatus, [string]$fakeZipPath) |
828 | | - |
829 | | - mkdir "$dir\OpenSSH-Win64" |
830 | | - $installSpyBehavior = "echo installed > $installScriptSpyStatus" |
831 | | - echo $installSpyBehavior > "$dir\OpenSSH-Win64\install-sshd.ps1" |
832 | | - echo "fake sshd" > "$dir\OpenSSH-Win64\sshd.exe" |
833 | | - |
834 | | - Compress-Archive -Force -Path "$dir\OpenSSH-Win64" -DestinationPath $fakeZipPath |
835 | | -} |
836 | | - |
837 | | -function CreateFakeLGPOZip |
838 | | -{ |
839 | | - param([string]$dir, [string]$fakeZipPath) |
840 | | - |
841 | | - New-Item -ItemType Directory "$dir\LGPO\LGPO_30" |
842 | | - echo "fake lgpo" > "$dir\LGPO\LGPO_30\LGPO.exe" |
843 | | - |
844 | | - Compress-Archive -Force -Path "$dir\LGPO\*" -DestinationPath $fakeZipPath |
845 | | -} |
846 | | - |
847 | 852 | Describe "Enable-SSHD" { |
848 | 853 | BeforeEach { |
849 | 854 | Mock Set-Service { } |
@@ -1021,9 +1026,6 @@ Describe "Extract-LGPO" { |
1021 | 1026 | } |
1022 | 1027 | } |
1023 | 1028 |
|
1024 | | -function Get-WuCerts { |
1025 | | -} |
1026 | | - |
1027 | 1029 | Describe "Install-WUCerts" { |
1028 | 1030 | It "executes the Get-WUCerts powershell cmdlet" { |
1029 | 1031 | Mock Get-WUCerts { } |
|
0 commit comments