microsoft / microsoft/CSS-Exchange
[Work Item] Pester test gap: Get-FilteredSettingOverrideInformation fallback path untested
Nobody has claimed this yet.
- Dominant language
- PowerShell
- Stars
- 1.3k
- Forks
- 395
- Avg merge
- 14h 7m
- Merged PRs (30d)
- 5
Description
Describe the work
Get-FilteredSettingOverrideInformation.ps1 has two data sources for setting overrides:
- Per-server
ExchangeSettingOverride(fromGet-ExchangeDiagnosticInfo→ VariantConfiguration) - Org-level
GetSettingOverride(fromGet-SettingOverridecmdlet) — used as fallback
The fallback path (lines 46-48) is never exercised in any Pester test because all VariantConfig mock files contain SimpleSettingOverrides entries, so the code always enters line 43-45 and never reaches the GetSettingOverride fallback.
# Get-FilteredSettingOverrideInformation.ps1 lines 42-56
# Use ExchangeSettingOverride first
if ($null -ne $ExchangeSettingOverride -and
$ExchangeSettingOverride.SimpleSettingOverrides.Count -gt 0) {
$findFromOverride = $ExchangeSettingOverride.SimpleSettingOverrides # <-- always hits this
} elseif ($null -ne $GetSettingOverride -and
$GetSettingOverride -ne "Unknown") {
$findFromOverride = $GetSettingOverride # <-- never tested
$usedAdSettings = $true
} elseif ($GetSettingOverride -eq "Unknown") {
$results.Add("Unknown") # <-- never tested
return
} else {
Write-Verbose "No data to filter"
return
}
Approach
1. Dedicated Pester test file for Get-FilteredSettingOverrideInformation
No test file currently exists. Create Diagnostics\HealthChecker\Tests\Get-FilteredSettingOverrideInformation.Tests.ps1 to unit test the function directly with controlled inputs covering all branches:
BeforeAll {
. $PSScriptRoot\..\Analyzer\Get-FilteredSettingOverrideInformation.ps1
}
Describe "Get-FilteredSettingOverrideInformation" {
Context "Per-server ExchangeSettingOverride path" {
It "Uses SimpleSettingOverrides when available" { }
It "Filters by ComponentName and SectionName correctly" { }
It "Returns null when filter finds no match" { }
It "Only adds Accepted status entries" { }
}
Context "Org-level GetSettingOverride fallback path" {
It "Falls through when ExchangeSettingOverride is null" { }
It "Falls through when SimpleSettingOverrides is empty" { }
It "Sets FromAdSettings to true" { }
It "Applies MinVersion/MaxVersion/Server filtering" { }
It "Returns DoesNotApply when version out of range" { }
}
Context "Edge cases" {
It "Returns 'Unknown' when GetSettingOverride is 'Unknown'" { }
It "Returns null when both sources are null" { }
It "Handles multiple overrides for same component" { }
}
}
2. Full HC integration test for the fallback scenario
Add a scenario in HealthChecker.SE.Scenarios.Tests.ps1 where Get-ExchangeDiagnosticInfo returns $null, forcing the pipeline to use org-level Get-SettingOverride data:
# In test BeforeAll:
Mock Get-ExchangeDiagnosticInfo -ParameterFilter {
$Process -eq "Microsoft.Exchange.Directory.TopologyService" -and
$Component -eq "VariantConfiguration" -and
$Argument -eq "Overrides"
} -MockWith { return $null }
# Use SO3 for signing disabled via org-level
Mock Get-SettingOverride { return Import-Clixml "$Script:MockDataCollectionRoot\Exchange\GetSettingOverride3.xml" }
Expected result: SerializedDataSigning Enabled = $false Red with "SerializedDataSigning is explicitly disabled"
What's untested
-
$usedAdSettings = $truepath — AD-based MinVersion/MaxVersion/Server filtering (lines 73-84) -
FromAdSettings = $truein returned result objects -
GetSettingOverride -eq "Unknown"path - SerializedDataSigning determined via org-level
Get-SettingOverride(GetSettingOverride3.xmlexists but is unreachable) - AMSI state determined via org-level fallback
- Hybrid app detection via org-level fallback
Additional context
GetSettingOverride3.xmlalready exists inDataCollection\ExchangeSE\Exchange\— 1 override:DisableSigningVerification(Component=Data, Section=EnableSerializationDataSigning, Enabled=false)- This fallback path is hit in production when
Get-ExchangeDiagnosticInfofails (TopologyService not running, permissions, network issues) Get-ExchangeSettingOverride.ps1line 55-56: ifdiagnosticInfois null,SimpleSettingOverridesstays as an empty list, triggering the fallback- Related files:
Get-SerializedDataSigningState.ps1,Invoke-AnalyzerSecurityAMSIConfigState.ps1,Invoke-AnalyzerHybridInformation.ps1— all callGet-FilteredSettingOverrideInformation
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with Diagnostics\HealthChecker\Analyzer\Get-FilteredSettingOverrideInformation.ps1 and the existing HealthChecker.SE.Scenarios.Tests.ps1 setup, then inspect the related analyzer callers and mock XML data. Add focused Pester coverage for both override sources and the Unknown/no-data branches, plus the integration fallback scenario; done means the relevant branches and expected SerializedDataSigning result are exercised.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell
- Domain
- testing-qa
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100