Skip to content

Commit

Permalink
Merge pull request #4269 from NikCharlebois/Fixes-Integration-Tests
Browse files Browse the repository at this point in the history
Fixes integration tests
  • Loading branch information
NikCharlebois authored Jan 30, 2024
2 parents 73127d4 + 97c7195 commit ea699f1
Show file tree
Hide file tree
Showing 38 changed files with 200 additions and 110 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,24 @@

# UNRELEASED

* EXOAvailabilityAddressSpace
* Added support for the TargetServiceEpr and TargetTenantId parameters.
* Fixed the logic to retrieve existing instance by Forest Name.
* EXODistributionGroup
* The Get function now retrieves the ModeratedBy and ManagedBy properties
by the users' UPN instead of their GUID.
* EXOHostedContentFilterRule
* Changed logic to retrieve the Rules by name. Using the Policy's name instead.
* EXOIntraOrganizationConnector
* Fixes the DiscoveryEndpoint value from the Get method to include trailing
forward slash.
* EXOMalwareFilterRule
* Fixed an issue retrieving the right value for the Enabled property
* EXOOMEConfiguration
* Fixes an error in the Get method where the ExternalMailExpiryInDays property
wasn't properly returned.
* EXOSafeLinksPolicy
* Deprecated the UseTranslatedNotificationText property
* 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 @@ -10,7 +10,7 @@ function Get-TargetResource
$Identity,

[Parameter()]
[ValidateSet('PerUserFB', 'OrgWideFB', 'OrgWideFBBasic', 'InternalProxy')]
[ValidateSet('PerUserFB', 'OrgWideFB', 'OrgWideFBToken', 'OrgWideFBBasic', 'InternalProxy')]
[System.String]
$AccessMethod,

Expand All @@ -26,6 +26,14 @@ function Get-TargetResource
[System.String]
$TargetAutodiscoverEpr,

[Parameter()]
[System.String]
$TargetServiceEpr,

[Parameter()]
[System.String]
$TargetTenantId,

[Parameter()]
[ValidateSet('Present', 'Absent')]
[System.String]
Expand Down Expand Up @@ -91,25 +99,21 @@ function Get-TargetResource
{
try
{
$AvailabilityAddressSpaces = Get-AvailabilityAddressSpace -ErrorAction Stop
$AvailabilityAddressSpace = Get-AvailabilityAddressSpace -Identity $ForestName -ErrorAction Stop
}
catch
{
New-M365DSCLogEntry -Message "Couldn't get AvailabilityAddressSpaces" `
-Exception $_ `
-Source $MyInvocation.MyCommand.ModuleName
}

$AvailabilityAddressSpace = $AvailabilityAddressSpaces | Where-Object -FilterScript { $_.Identity -eq $Identity }
if ($null -eq $AvailabilityAddressSpace)
{
Write-Verbose -Message "AvailabilityAddressSpace $($Identity) does not exist."
Write-Verbose -Message "AvailabilityAddressSpace $($ForestName) does not exist."
return $nullReturn
}
else
{


if ($Null -eq $AvailabilityAddressSpace.TargetAutodiscoverEpr -or $AvailabilityAddressSpace.TargetAutodiscoverEpr -eq '' )
{
$TargetAutodiscoverEpr = ''
Expand All @@ -123,6 +127,8 @@ function Get-TargetResource
Identity = $Identity
AccessMethod = $AvailabilityAddressSpace.AccessMethod
Credentials = $AvailabilityAddressSpace.Credentials
TargetServiceEpr = $AvailabilityAddressSpace.TargetServiceEpd
TargetTenantId = $AvailabilityAddressSpace.TargetTenantId
ForestName = $AvailabilityAddressSpace.ForestName
TargetAutodiscoverEpr = $TargetAutodiscoverEpr
Credential = $Credential
Expand Down Expand Up @@ -163,7 +169,7 @@ function Set-TargetResource
$Identity,

[Parameter()]
[ValidateSet('PerUserFB', 'OrgWideFB', 'OrgWideFBBasic', 'InternalProxy')]
[ValidateSet('PerUserFB', 'OrgWideFB', 'OrgWideFBToken', 'OrgWideFBBasic', 'InternalProxy')]
[System.String]
$AccessMethod,

Expand All @@ -179,6 +185,14 @@ function Set-TargetResource
[System.String]
$TargetAutodiscoverEpr,

[Parameter()]
[System.String]
$TargetServiceEpr,

[Parameter()]
[System.String]
$TargetTenantId,

[Parameter()]
[ValidateSet('Present', 'Absent')]
[System.String]
Expand Down Expand Up @@ -323,7 +337,7 @@ function Test-TargetResource
$Identity,

[Parameter()]
[ValidateSet('PerUserFB', 'OrgWideFB', 'OrgWideFBBasic', 'InternalProxy')]
[ValidateSet('PerUserFB', 'OrgWideFB', 'OrgWideFBToken', 'OrgWideFBBasic', 'InternalProxy')]
[System.String]
$AccessMethod,

Expand All @@ -339,6 +353,14 @@ function Test-TargetResource
[System.String]
$TargetAutodiscoverEpr,

[Parameter()]
[System.String]
$TargetServiceEpr,

[Parameter()]
[System.String]
$TargetTenantId,

[Parameter()]
[ValidateSet('Present', 'Absent')]
[System.String]
Expand Down Expand Up @@ -399,6 +421,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
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class MSFT_EXOAvailabilityAddressSpace : OMI_BaseResource
{
[Key, Description("The Identity parameter specifies the AvailabilityAddressSpace you want to modify.")] String Identity;
[Write, Description("The AccessMethod parameter specifies how the free/busy data is accessed. Valid values are:PerUserFB, OrgWideFB, OrgWideFBBasic,InternalProxy"), ValueMap{"PerUserFB","OrgWideFB","OrgWideFBBasic","InternalProxy"}, Values{"PerUserFB","OrgWideFB","OrgWideFBBasic","InternalProxy"}] String AccessMethod;
[Write, Description("The AccessMethod parameter specifies how the free/busy data is accessed. Valid values are:PerUserFB, OrgWideFB, OrgWideFBToken, OrgWideFBBasic,InternalProxy"), ValueMap{"PerUserFB","OrgWideFB","OrgWideFBToken","OrgWideFBBasic","InternalProxy"}, Values{"PerUserFB","OrgWideFB","OrgWideFBToken","OrgWideFBBasic","InternalProxy"}] String AccessMethod;
[Write, Description("The Credentials parameter specifies the username and password that's used to access the Availability services in the target forest.")] String Credentials;
[Write, Description("The ForestName parameter specifies the SMTP domain name of the target forest for users whose free/busy data must be retrieved. If your users are distributed among multiple SMTP domains in the target forest, run the Add-AvailabilityAddressSpace command once for each SMTP domain.")] String ForestName;
[Write, Description("The TargetAutodiscoverEpr parameter specifies the Autodiscover URL of Exchange Web Services for the external organization. Exchange uses Autodiscover to automatically detect the correct server endpoint for external requests.")] String TargetAutodiscoverEpr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ function Get-TargetResource
-InboundParameters $PSBoundParameters
}

$ConnectionMode = New-M365DSCConnection -Workload 'MicrosoftGraph' `
-InboundParameters $PSBoundParameters

#Ensure the proper dependencies are installed in the current environment.
Confirm-M365DSCDependencies

Expand All @@ -76,15 +79,16 @@ function Get-TargetResource

if ($null -ne $AvailabilityConfigs -and $null -ne $AvailabilityConfigs.OrgWideAccount)
{
$AvailabilityConfig = ($AvailabilityConfigs | Where-Object -FilterScript { $_.OrgWideAccount -IMatch $OrgWideAccount })
$user = Get-MgUser -UserId $OrgWideAccount -ErrorAction Stop
$AvailabilityConfig = ($AvailabilityConfigs | Where-Object -FilterScript { $_.OrgWideAccount -IMatch $user.UserId })
}
if ($null -eq $AvailabilityConfig)
{
Write-Verbose -Message "Availability config for $($OrgWideAccount) does not exist."
return $nullReturn
}
$result = @{
OrgWideAccount = $AvailabilityConfig.OrgWideAccount
OrgWideAccount = $OrgWideAccount
Ensure = 'Present'
Credential = $Credential
ApplicationId = $ApplicationId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,39 @@ function Get-TargetResource
$groupTypeValue = 'Security'
}

$ManagedByValue = @()
if ($null -ne $distributionGroup.ManagedBy)
{
foreach ($user in $distributionGroup.ManagedBy)
{
try
{
$user = Get-MgUser -UserId $user -ErrorAction Stop
$ManagedByValue += $user.UserPrincipalName
}
catch
{
Write-Verbose -Message "Couldn't retrieve user {$user}"
}
}
}

$ModeratedByValue = @()
if ($null -ne $distributionGroup.ModeratedBy)
{
foreach ($user in $distributionGroup.ModeratedBy)
{
try
{
$user = Get-MgUser -UserId $user -ErrorAction Stop
$ModeratedByValue += $user.UserPrincipalName
}
catch
{
Write-Verbose -Message "Couldn't retrieve moderating user {$user}"
}
}
}
$result = @{
Identity = $distributionGroup.Identity
Alias = $distributionGroup.Alias
Expand All @@ -308,11 +341,11 @@ function Get-TargetResource
Description = $descriptionValue
DisplayName = $distributionGroup.DisplayName
HiddenGroupMembershipEnabled = $distributionGroup.HiddenGroupMembershipEnabled
ManagedBy = $distributionGroup.ManagedBy
ManagedBy = $ManagedByValue
MemberDepartRestriction = $distributionGroup.MemberDepartRestriction
MemberJoinRestriction = $distributionGroup.MemberJoinRestriction
Members = $distributionGroupMembers.Name
ModeratedBy = $distributionGroup.ModeratedBy
ModeratedBy = $ModeratedByValue
ModerationEnabled = $distributionGroup.ModerationEnabled
Name = $distributionGroup.Name
Notes = $distributionGroup.Notes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ function Get-TargetResource
[System.Boolean]
$DownloadLink = $false,

#DEPRECATED
[Parameter()]
[System.Boolean]
$EnableEndUserSpamNotifications = $false,
Expand Down Expand Up @@ -302,9 +303,7 @@ function Get-TargetResource
$nullReturn.Ensure = 'Absent'
try
{
$HostedContentFilterPolicies = Get-HostedContentFilterPolicy -ErrorAction Stop

$HostedContentFilterPolicy = $HostedContentFilterPolicies | Where-Object -FilterScript { $_.Identity -eq $Identity }
$HostedContentFilterPolicy = Get-HostedContentFilterPolicy -Identity $Identity -ErrorAction Stop
if ($null -eq $HostedContentFilterPolicy)
{
Write-Verbose -Message "HostedContentFilterPolicy $($Identity) does not exist."
Expand Down Expand Up @@ -344,12 +343,14 @@ function Get-TargetResource
BulkSpamAction = $HostedContentFilterPolicy.BulkSpamAction
BulkThreshold = $HostedContentFilterPolicy.BulkThreshold
DownloadLink = $HostedContentFilterPolicy.DownloadLink
EnableEndUserSpamNotifications = $HostedContentFilterPolicy.EnableEndUserSpamNotifications
#Deprecated
#EnableEndUserSpamNotifications = $HostedContentFilterPolicy.EnableEndUserSpamNotifications
EnableLanguageBlockList = $HostedContentFilterPolicy.EnableLanguageBlockList
EnableRegionBlockList = $HostedContentFilterPolicy.EnableRegionBlockList
EndUserSpamNotificationCustomSubject = $HostedContentFilterPolicy.EndUserSpamNotificationCustomSubject
EndUserSpamNotificationFrequency = $HostedContentFilterPolicy.EndUserSpamNotificationFrequency
EndUserSpamNotificationLanguage = $HostedContentFilterPolicy.EndUserSpamNotificationLanguage
#Deprecated
#EndUserSpamNotificationCustomSubject = $HostedContentFilterPolicy.EndUserSpamNotificationCustomSubject
#EndUserSpamNotificationFrequency = $HostedContentFilterPolicy.EndUserSpamNotificationFrequency
#EndUserSpamNotificationLanguage = $HostedContentFilterPolicy.EndUserSpamNotificationLanguage
HighConfidencePhishAction = $HostedContentFilterPolicy.HighConfidencePhishAction
HighConfidencePhishQuarantineTag = $HostedContentFilterPolicy.HighConfidencePhishQuarantineTag
HighConfidenceSpamAction = $HostedContentFilterPolicy.HighConfidenceSpamAction
Expand Down Expand Up @@ -406,6 +407,7 @@ function Get-TargetResource
}
catch
{
Write-Verbose -Message $_
New-M365DSCLogEntry -Message 'Error retrieving data:' `
-Exception $_ `
-Source $($MyInvocation.MyCommand.Source) `
Expand Down Expand Up @@ -1055,6 +1057,10 @@ function Test-TargetResource
$ValuesToCheck.Remove('CertificatePath') | Out-Null
$ValuesToCheck.Remove('CertificatePassword') | Out-Null
$ValuesToCheck.Remove('ManagedIdentity') | Out-Null
$ValuesToCheck.Remove('EnableEndUserSpamNotifications') | Out-Null
$ValuesToCheck.Remove('EndUserSpamNotificationLanguage') | Out-Null
$ValuesToCheck.Remove('EndUserSpamNotificationFrequency') | Out-Null
$ValuesToCheck.Remove('EndUserSpamNotificationCustomSubject') | Out-Null

$TestResult = Test-M365DSCParameterState -CurrentValues $CurrentValues `
-Source $($MyInvocation.MyCommand.Source) `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ function Get-TargetResource
}
else
{
$DiscoveryEndpointValue = $IntraOrganizationConnector.DiscoveryEndpoint.ToString()
if (-not $DiscoveryEndpointValue.EndsWith('/'))
{
$DiscoveryEndpointValue += '/'
}
$result = @{
Identity = $Identity
DiscoveryEndpoint = $IntraOrganizationConnector.DiscoveryEndpoint.ToString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,23 @@ function Get-TargetResource
$nullReturn.Ensure = 'Absent'
try
{
$MalwareFilterRules = Get-MalwareFilterRule -ErrorAction Stop

$MalwareFilterRule = $MalwareFilterRules | Where-Object -FilterScript { $_.Identity -eq $Identity }
$MalwareFilterRule = Get-MalwareFilterRule -Identity $Identity -ErrorAction SilentlyContinue
if ($null -eq $MalwareFilterRule)
{
Write-Verbose -Message "MalwareFilterRule $($Identity) does not exist."
return $nullReturn
}
else
{
$EnabledValue = $false
if ($MalwareFilterRule.State -eq 'Enabled')
{
$EnabledValue = $true
}
$result = @{
Identity = $Identity
Comments = $MalwareFilterRule.Comments
Enabled = $MalwareFilterRule.Enabled
Enabled = $EnabledValue
ExceptIfRecipientDomainIs = $MalwareFilterRule.ExceptIfRecipientDomainIs
ExceptIfSentTo = $MalwareFilterRule.ExceptIfSentTo
ExceptIfSentToMemberOf = $MalwareFilterRule.ExceptIfSentToMemberOf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,8 @@ function Get-TargetResource

try
{
$MessageClassifications = Get-MessageClassification -ErrorAction Stop
$MessageClassification = Get-MessageClassification -Identity $Identity -ErrorAction Stop

$MessageClassification = $MessageClassifications | Where-Object -FilterScript { $_.Identity -eq $Identity }
if ($null -eq $MessageClassification)
{
Write-Verbose -Message "Message Classification policy $($Identity) does not exist."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function Get-TargetResource
BackgroundColor = $OMEConfiguration.BackgroundColor
DisclaimerText = $OMEConfiguration.DisclaimerText
EmailText = $OMEConfiguration.EmailText
ExternalMailExpiryInDays = $OMEConfiguration.ExternalMailExpiryInDays
ExternalMailExpiryInDays = $OMEConfiguration.ExternalMailExpiryInterval.Days
# Image = $OMEConfiguration.Image
IntroductionText = $OMEConfiguration.IntroductionText
OTPEnabled = $OMEConfiguration.OTPEnabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,9 @@ function Get-TargetResource
$nullReturn.Ensure = 'Absent'
try
{
Write-Verbose -Message 'Global ExchangeOnlineSession status:'
Write-Verbose -Message "$( Get-PSSession -ErrorAction SilentlyContinue | Where-Object -FilterScript { $_.Name -eq 'ExchangeOnline' } | Out-String)"

try
{
$SafeLinksPolicies = Get-SafeLinksPolicy -ErrorAction Stop
$SafeLinksPolicy = Get-SafeLinksPolicy -Identity $Identity -ErrorAction Stop
}
catch
{
Expand All @@ -141,8 +138,6 @@ function Get-TargetResource
-Exception $_ `
-Source $MyInvocation.MyCommand.ModuleName
}

$SafeLinksPolicy = $SafeLinksPolicies | Where-Object -FilterScript { $_.Identity -eq $Identity }
if (-not $SafeLinksPolicy)
{
Write-Verbose -Message "SafeLinksPolicy $($Identity) does not exist."
Expand All @@ -165,7 +160,8 @@ function Get-TargetResource
DisableUrlRewrite = $SafeLinksPolicy.DisableUrlRewrite
ScanUrls = $SafeLinksPolicy.ScanUrls
TrackClicks = $SafeLinksPolicy.TrackClicks
UseTranslatedNotificationText = $SafeLinksPolicy.UseTranslatedNotificationText
# The Get-SafeLinksPolicy no longer returns this property
# UseTranslatedNotificationText = $SafeLinksPolicy.UseTranslatedNotificationText
Ensure = 'Present'
Credential = $Credential
ApplicationId = $ApplicationId
Expand Down Expand Up @@ -472,6 +468,7 @@ function Test-TargetResource
$ValuesToCheck.Remove('CertificatePath') | Out-Null
$ValuesToCheck.Remove('CertificatePassword') | Out-Null
$ValuesToCheck.Remove('ManagedIdentity') | Out-Null
$ValuesToCheck.Remove('UseTranslatedNotificationText') | Out-Null

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

0 comments on commit ea699f1

Please sign in to comment.