Skip to content

Commit

Permalink
Merge pull request #4266 from NikCharlebois/EXOIntegration
Browse files Browse the repository at this point in the history
Updated Integration Tests for EXO
  • Loading branch information
NikCharlebois authored Jan 30, 2024
2 parents 6c61af4 + 3986ef8 commit 8f614c0
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 69 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

# UNRELEASED

* EXOHostedContentFilterRule
* Changed logic to retrieve the Rules by name. Using the Policy's name instead.
* TeamsEmergencyCallRoutingPolicy
* Fix deletion of resource
FIXES [#4261](https://github.com/microsoft/Microsoft365DSC/issues/4261)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function Get-TargetResource

try
{
$HostedConnectionFilterPolicys = Get-HostedConnectionFilterPolicy -ErrorAction Stop
$HostedConnectionFilterPolicy = Get-HostedConnectionFilterPolicy -Identity $Identity -ErrorAction Stop
}
catch
{
Expand All @@ -107,10 +107,9 @@ function Get-TargetResource
return $nullReturn
}

$HostedConnectionFilterPolicy = $HostedConnectionFilterPolicys | Where-Object -FilterScript { $_. Identity -eq $Identity }
if (-not $HostedConnectionFilterPolicy)
{
Write-Verbose -Message "HostedConnectionFilterPolicy $($Identity) does not exist."
Write-Verbose -Message "HostedConnectionFilterPolicy [$($Identity)] does not exist."
return $nullReturn
}
else
Expand Down Expand Up @@ -234,9 +233,7 @@ function Set-TargetResource
$ConnectionMode = New-M365DSCConnection -Workload 'ExchangeOnline' `
-InboundParameters $PSBoundParameters

$HostedConnectionFilterPolicys = Get-HostedConnectionFilterPolicy

$HostedConnectionFilterPolicy = $HostedConnectionFilterPolicys | Where-Object -FilterScript { $_.Identity -eq $Identity }
$CurrentInstance = Get-TargetResource @PSBoundParameters

$HostedConnectionFilterPolicyParams = [System.Collections.Hashtable]($PSBoundParameters)
$HostedConnectionFilterPolicyParams.Remove('Ensure') | Out-Null
Expand All @@ -257,22 +254,26 @@ function Set-TargetResource
$HostedConnectionFilterPolicyParams.Remove('RuleScope') | Out-Null
}

if (('Present' -eq $Ensure ) -and ($null -eq $HostedConnectionFilterPolicy))
if (('Present' -eq $Ensure ) -and $CurrentInstance.Ensure -eq 'Absent')
{
$HostedConnectionFilterPolicyParams += @{
Name = $HostedConnectionFilterPolicyParams.Identity
}
$HostedConnectionFilterPolicyParams.Remove('Identity') | Out-Null
if ($PSBoundParameters.MakeDefault)
{
Write-Verbose -Message "Creating New Default Policy {$Identity}"
New-HostedConnectionFilterPolicy @HostedConnectionFilterPolicyParams -MakeDefault
}
else
{
Write-Verbose -Message "Creating New Policy {$Identity}"
New-HostedConnectionFilterPolicy @HostedConnectionFilterPolicyParams
}

Write-Verbose -Message "With Parameters: $(Convert-M365DscHashtableToString -Hashtable $HostedConnectionFilterPolicyParams)"
}
elseif (('Present' -eq $Ensure ) -and ($HostedConnectionFilterPolicy))
elseif (('Present' -eq $Ensure ) -and $CurrentInstance.Ensure -eq 'Present')
{
if ($PSBoundParameters.MakeDefault)
{
Expand All @@ -283,9 +284,9 @@ function Set-TargetResource
Set-HostedConnectionFilterPolicy @HostedConnectionFilterPolicyParams -Confirm:$false
}
}
elseif (('Absent' -eq $Ensure ) -and ($HostedConnectionFilterPolicy))
elseif (('Absent' -eq $Ensure ) -and $CurrentInstance.Ensure -eq 'Present')
{
Write-Verbose -Message "Removing HostedConnectionFilterPolicy $($Identity) "
Write-Verbose -Message "Removing HostedConnectionFilterPolicy $($Identity)"
Remove-HostedConnectionFilterPolicy -Identity $Identity -Confirm:$false
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ function Get-TargetResource
{
try
{
$HostedContentFilterRules = Get-HostedContentFilterRule -ErrorAction Stop
$HostedContentFilterRule = Get-HostedContentFilterRule -Identity $HostedContentFilterPolicy -ErrorAction Stop
}
catch
{
Expand All @@ -123,8 +123,6 @@ function Get-TargetResource
-Exception $_ `
-Source $MyInvocation.MyCommand.ModuleName
}

$HostedContentFilterRule = $HostedContentFilterRules | Where-Object -FilterScript { $_.Identity -eq $Identity }
if (-not $HostedContentFilterRule)
{
Write-Verbose -Message "HostedContentFilterRule $($Identity) does not exist."
Expand Down Expand Up @@ -316,6 +314,7 @@ function Set-TargetResource
Remove-HostedContentFilterRule -Identity $Identity -Confirm:$false
}
Write-Verbose -Message "Creating new HostedContentFilterRule {$Identity}"
Write-Verbose -Message "With Parameters: $(Convert-M365DscHashtableToString -Hashtable $CreationParams)"
$CreationParams.Add('Name', $Identity)
$CreationParams.Remove('Identity') | Out-Null
New-HostedContentFilterRule @CreationParams
Expand All @@ -332,6 +331,7 @@ function Set-TargetResource
$UpdateParams.Remove('CertificatePassword') | Out-Null
$UpdateParams.Remove('ManagedIdentity') | Out-Null
$UpdateParams.Remove('Enabled') | Out-Null
$UpdateParams.Identity = $HostedContentFilterPolicy
if ($CurrentValues.HostedContentFilterPolicy -eq $UpdateParams.HostedContentFilterPolicy )
{
$UpdateParams.Remove('HostedContentFilterPolicy') | Out-Null
Expand Down Expand Up @@ -456,6 +456,7 @@ function Test-TargetResource
$ValuesToCheck.Remove('CertificatePath') | Out-Null
$ValuesToCheck.Remove('CertificatePassword') | Out-Null
$ValuesToCheck.Remove('ManagedIdentity') | Out-Null
$ValuesToCheck.Remove('Identity') | Out-Null

$TestResult = Test-M365DSCParameterState -CurrentValues $CurrentValues `
-Source $($MyInvocation.MyCommand.Source) `
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ Configuration Example
{
EXOHostedConnectionFilterPolicy 'ConfigureHostedConnectionFilterPolicy'
{
Identity = "Integration Policy"
Identity = "Default"
AdminDisplayName = ""
EnableSafeList = $True # Updated Property
IPAllowList = @()
IPBlockList = @()
MakeDefault = $False
MakeDefault = $True
Ensure = "Present"
Credential = $Credscredential
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,25 @@ Configuration Example
OutboundConnector = 'Contoso Outbound Connector'
Ensure = 'Present'
Credential = $Credscredential
DependsOn = "[EXOOutboundConnector]ConfigureOutboundConnector"
DependsOn = "[EXOOutboundConnector]OutboundDependency"
}
EXOOutboundConnector 'OutboundDependency'
{
Identity = "Contoso Outbound Connector"
AllAcceptedDomains = $False
CloudServicesMailEnabled = $False
Comment = "Outbound connector to Contoso"
ConnectorSource = "Default"
ConnectorType = "Partner"
Enabled = $True
IsTransportRuleScoped = $False
RecipientDomains = "contoso.com"
RouteAllMessagesViaOnPremises = $False
TlsDomain = "*.contoso.com"
TlsSettings = "DomainValidation"
UseMxRecord = $True
Ensure = "Present"
Credential = $Credscredential
}
}
}

0 comments on commit 8f614c0

Please sign in to comment.