Removed extension attribute requirement for testing

This commit is contained in:
2026-08-21 00:31:47 -04:00
parent cdc6bb33d3
commit aeedb7170a
4 changed files with 125 additions and 4 deletions
+62
View File
@@ -142,6 +142,68 @@ Describe 'Exit codes produced by the run loop' {
}
}
Describe 'Target attribute unavailable - dev tenants without an app registration' {
BeforeAll {
$script:unavailableError = "Response status code does not indicate success: 400 (Bad Request): Could not find a property named '$($script:target)' on type 'microsoft.graph.user'."
}
BeforeEach {
Mock Write-Host { }
Mock Write-Verbose { }
Mock Write-Warning { }
}
It 'continues in What-If mode, treating the attribute as null, when it is not registered' {
Mock Get-PersonaUsers {
param($SelectProperties, $UserObjectId, $PageSize)
if ($SelectProperties -ccontains $script:target) { throw $script:unavailableError }
@(New-TestPopulation -Count 5 -TargetAttribute $script:target)
}
$outcome = Invoke-PersonaEngineRun -Configuration (New-TestRuntimeConfiguration -TargetAttribute $script:target) `
-TargetAttribute $script:target -Context (New-TestAuditContext) -IsEnforcing:$false
$outcome.ExitCode | Should -Be 0
$outcome.Counters.Processed | Should -Be 5
Should -Invoke Get-PersonaUsers -Times 2 -Exactly
Should -Invoke Write-Warning -Times 1 -Exactly
}
It 'requests everything except the target attribute on the retry' {
Mock Get-PersonaUsers {
param($SelectProperties, $UserObjectId, $PageSize)
if ($SelectProperties -ccontains $script:target) { throw $script:unavailableError }
@(New-TestPopulation -Count 5 -TargetAttribute $script:target)
}
$null = Invoke-PersonaEngineRun -Configuration (New-TestRuntimeConfiguration -TargetAttribute $script:target) `
-TargetAttribute $script:target -Context (New-TestAuditContext) -IsEnforcing:$false
Should -Invoke Get-PersonaUsers -Times 1 -Exactly -ParameterFilter { $SelectProperties -cnotcontains $script:target }
}
It 'still fails enumeration in enforcement mode - the fallback never applies to a real write run' {
Mock Get-PersonaUsers { throw $script:unavailableError }
$outcome = Invoke-PersonaEngineRun -Configuration (New-TestRuntimeConfiguration -TargetAttribute $script:target) `
-TargetAttribute $script:target -Context (New-TestAuditContext -Mode 'Enforce') -IsEnforcing
$outcome.ExitCode | Should -Be 3
Should -Invoke Get-PersonaUsers -Times 1 -Exactly
}
It 'does not swallow an unrelated enumeration failure even in What-If mode' {
Mock Get-PersonaUsers { throw 'Graph request failed after 5 attempt(s) (last status: 503): service unavailable' }
$outcome = Invoke-PersonaEngineRun -Configuration (New-TestRuntimeConfiguration -TargetAttribute $script:target) `
-TargetAttribute $script:target -Context (New-TestAuditContext) -IsEnforcing:$false
$outcome.ExitCode | Should -Be 3
Should -Invoke Get-PersonaUsers -Times 1 -Exactly
}
}
Describe 'Exit codes owned by the entry script' {
BeforeAll {