Skip to content

Commit

Permalink
Improve pester testing on Exchange Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
dpaulson45 committed Aug 6, 2024
1 parent 6554c55 commit 8ea1d3b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ function Invoke-AnalyzerExchangeInformation {
$params = $baseParams + @{
Details = "$kbName - Installed on $($kbInfo.InstalledDate)"
DisplayCustomTabNumber = 2
TestingName = "Exchange IU"
}
Add-AnalyzedResultInformation @params

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,33 @@ Describe "Testing Health Checker by Mock Data Imports" {
if ($Name -eq "MSExchangeMitigation") { return Import-Clixml "$Script:MockDataCollectionRoot\Exchange\GetServiceMitigation.xml" }
return Import-Clixml "$Script:MockDataCollectionRoot\OS\GetService1.xml"
}
Mock Get-RemoteRegistrySubKey -ParameterFilter { $SubKey -eq "SOFTWARE\Microsoft\Updates\Exchange 2019" } -MockWith {
$obj = New-Object System.Collections.Generic.List[object]
$suObject = [PSCustomObject]@{
Name = "Empty"
}
$suObject | Add-Member -MemberType ScriptMethod -Name GetSubKeyNames -Value { return @("KB5029388", "KB5030877") }
$suObject | Add-Member -MemberType ScriptMethod -Name OpenSubKey -Value { param($id) if ($id -eq "KB5029388") {
$o = [PSCustomObject]@{
Name = "Empty"
}
$o | Add-Member -MemberType ScriptMethod -Name GetValue -Value { param ($name) if ($name -eq "PackageName") {
return "Security Update for Exchange Server 2019 Cumulative Update 12 (KB5029388)"
} elseif ( $name -eq "InstalledDate") { return "9/20/2023" } }
return $o
} elseif ($id -eq "KB5030877") {
$o = [PSCustomObject]@{
Name = "Empty"
}
$o | Add-Member -MemberType ScriptMethod -Name GetValue -Value { param ($name) if ($name -eq "PackageName") {
return "Security Update for Exchange Server 2019 Cumulative Update 12 (KB5030877)"
} elseif ( $name -eq "InstalledDate") { return "10/20/2023" } }
return $o
}
}
$obj.Add($suObject)
return $obj
}

SetDefaultRunOfHealthChecker "Debug_Scenario1_Results.xml"
}
Expand All @@ -82,6 +109,8 @@ Describe "Testing Health Checker by Mock Data Imports" {
TestObjectMatch "Exchange Server Membership" "Failed" -WriteType "Red"
TestObjectMatch "Exchange Trusted Subsystem - Local System Membership" "Exchange Trusted Subsystem - Local System Membership" -WriteType "Red"
TestObjectMatch "Exchange Trusted Subsystem - AD Group Membership" "Exchange Trusted Subsystem - AD Group Membership" -WriteType "Red"
$hotfixInstalled = GetObject "Exchange IU"
$hotfixInstalled.Count | Should -Be 2
}

It "Dependent Services" {
Expand Down

0 comments on commit 8ea1d3b

Please sign in to comment.