Skip to content

Commit

Permalink
Merge pull request #4820 from ricmestre/fix4819
Browse files Browse the repository at this point in the history
EXOAuthenticationPolicy: Recreate policy instead of changing it
  • Loading branch information
NikCharlebois authored Oct 2, 2024
2 parents 99b1ac8 + 3fdedaf commit 60af821
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
* Use correct type integer for variable `PhishThresholdLevel`
* EXOArcConfig
* Initial Release.
* EXOAuthenticationPolicy
* If policy needs changes then recreate it to avoid issue with
`Set-AuthenticationPolicy` cmdlet
FIXES [#4819](https://github.com/microsoft/Microsoft365DSC/issues/4819)
* EXODnssecForVerifiedDomain
* Initial Release.
* EXOEmailTenantSettings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,12 @@ function Set-TargetResource
Remove-AuthenticationPolicy -Identity $Identity -Confirm:$false
}
# CASE: Authentication Policy exists and it should, but has different values than the desired one
# Policy cannot be changed so it must be deleted and re-created again
elseif ($Ensure -eq 'Present' -and $currentAuthenticationPolicyConfig.Ensure -eq 'Present')
{
Write-Verbose -Message "Authentication Policy '$($Identity)' exists. Updating settings."
Set-AuthenticationPolicy -Identity $Identity @NewAuthenticationPolicyParams | Out-Null
Remove-AuthenticationPolicy -Identity $Identity -Confirm:$false
New-AuthenticationPolicy -Name $Identity @NewAuthenticationPolicyParams | Out-Null
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
Mock -CommandName New-AuthenticationPolicy {
}

Mock -CommandName Set-AuthenticationPolicy {
}

Mock -CommandName Remove-AuthenticationPolicy {
}

Expand Down Expand Up @@ -195,7 +192,8 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture {

It 'Should call the Set method' {
Set-TargetResource @testParams
Should -Invoke -CommandName Set-AuthenticationPolicy -Exactly 1
Should -Invoke -CommandName Remove-AuthenticationPolicy -Exactly 1
Should -Invoke -CommandName New-AuthenticationPolicy -Exactly 1
}
}

Expand Down

0 comments on commit 60af821

Please sign in to comment.