@@ -4,14 +4,6 @@ Import-Module ./BOSH.CFCell.psm1
44Remove-Module - Name BOSH.Utils - ErrorAction Ignore
55Import-Module ../ BOSH.Utils/ BOSH.Utils.psm1
66
7- # this function does not exist on VMs without Windows Defender installed
8- function Set-MpPreference () {
9- param (
10- [bool ]$DisableBehaviorMonitoring ,
11- [bool ]$OtherThing
12- )
13- }
14-
157Describe " Protect-CFCell" {
168 BeforeEach {
179 $oldWinRMStatus = (Get-Service winrm).Status
@@ -20,10 +12,6 @@ Describe "Protect-CFCell" {
2012 { Set-Service - Name " winrm" - StartupType " Manual" } | Should Not Throw
2113
2214 Start-Service winrm
23-
24- Mock Get-Command { [hashtable ]@ {ParameterSets = [hashtable ]@ {Parameters = @ ()}} } - ModuleName BOSH.CFCell
25- Mock Write-Log {} - ModuleName BOSH.CFCell
26-
2715 }
2816
2917 AfterEach {
@@ -68,40 +56,6 @@ Describe "Protect-CFCell" {
6856 get-firewall " private" | Should be " private,Block,Allow"
6957 get-firewall " domain" | Should be " domain,Block,Allow"
7058 }
71-
72- It " sets all Windows Defender `disable` settings to true" {
73- Mock Get-Command {
74- [hashtable ]@ {
75- ParameterSets = [hashtable ]@ {
76- Parameters = @ (
77- @ {Name = " DisableBehaviorMonitoring" },
78- @ {Name = " OtherThing" }
79- )
80- }
81- }
82- } - ModuleName BOSH.CFCell
83- Mock Set-MpPreference { } - ModuleName BOSH.CFCell
84-
85- Protect-CFCell
86-
87- Assert-MockCalled Write-Log - Exactly 1 - Scope It - ModuleName BOSH.CFCell - ParameterFilter { $Message -eq " Disabling Windows Defender Features" }
88-
89- Assert-MockCalled Set-MpPreference - Exactly 1 - Scope It - ParameterFilter { $DisableBehaviorMonitoring -eq $true } - ModuleName BOSH.CFCell
90- Assert-MockCalled Set-MpPreference - Exactly 0 - Scope It - ParameterFilter { $OtherThing -eq $true } - ModuleName BOSH.CFCell
91-
92- Assert-MockCalled Write-Log - Exactly 1 - Scope It - ModuleName BOSH.CFCell - ParameterFilter { $Message -eq " Setting Defender preference DisableBehaviorMonitoring to True" }
93- }
94-
95- It " does not attempt to change Windows Defender settings if Windows Defender is not installed" {
96- Mock Get-Command { $false } - ModuleName BOSH.CFCell
97- Mock Set-MpPreference { } - ModuleName BOSH.CFCell
98-
99- Protect-CFCell
100-
101- Assert-MockCalled Write-Log - Exactly 1 - Scope It - ModuleName BOSH.CFCell - ParameterFilter { $Message -eq " Set-MpPreference command not found, assuming Windows Defender is not installed" }
102- Assert-MockCalled Set-MpPreference - Scope It - Exactly 0 - ModuleName BOSH.CFCell
103- }
104-
10559}
10660
10761Describe " Install-CFFeatures" {
0 commit comments