Skip to content

Commit

Permalink
Merge pull request #4893 from NikCharlebois/Tests-Improvements
Browse files Browse the repository at this point in the history
Fixes to Tests and EXOHostedOutboundSpamFilterPolicy
  • Loading branch information
NikCharlebois committed Jul 16, 2024
2 parents 06f729c + 2d8ca47 commit 64bf481
Show file tree
Hide file tree
Showing 25 changed files with 39 additions and 43 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

# UNRELEASED

* EXOHostedOutboundSpamFilterPolicy
* Changed the RecipientLimitInternalPerHour, RecipientLimitPerDay, and
RecipientLimitExternalPerHour parameters to UInt32.
* M365DSCReport
* Changes behaviour to not throw on empty configuration during report generation.
FIXES [#4559](https://github.com/microsoft/Microsoft365DSC/issues/4559)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function Get-TargetResource
$AccessTokens
)

Write-Verbose -Message "Getting configuration of HostedContentFilterRule for $Identity"
Write-Verbose -Message "Getting configuration of HostedContentFilterRule for [$Identity]"

#Ensure the proper dependencies are installed in the current environment.
Confirm-M365DSCDependencies
Expand Down Expand Up @@ -122,10 +122,19 @@ function Get-TargetResource
}
catch
{
$Message = 'Error calling {Get-HostedContentFilterRule}'
New-M365DSCLogEntry -Message $Message `
-Exception $_ `
-Source $MyInvocation.MyCommand.ModuleName
try
{
Write-Verbose -Message "Couldn't find rule by ID, trying by name."
$rules = Get-HostedContentFilterRule
$HostedContentFilterRule = $rules | Where-Object -FilterScript {$_.Name -eq $Identity -and $_.HostedContentFilterPolicy -eq $HostedContentFilterPolicy}
}
catch
{
$Message = 'Error calling {Get-HostedContentFilterRule}'
New-M365DSCLogEntry -Message $Message `
-Exception $_ `
-Source $MyInvocation.MyCommand.ModuleName
}
}
if (-not $HostedContentFilterRule)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ function Get-TargetResource
$NotifyOutboundSpam = $true,

[Parameter()]
[System.String]
[System.UInt32]
$RecipientLimitInternalPerHour,

[Parameter()]
[System.String]
[System.UInt32]
$RecipientLimitPerDay,

[Parameter()]
[System.String]
[System.UInt32]
$RecipientLimitExternalPerHour,

[Parameter()]
Expand Down Expand Up @@ -196,15 +196,15 @@ function Set-TargetResource
$NotifyOutboundSpam = $true,

[Parameter()]
[System.String]
[System.UInt32]
$RecipientLimitInternalPerHour,

[Parameter()]
[System.String]
[System.UInt32]
$RecipientLimitPerDay,

[Parameter()]
[System.String]
[System.UInt32]
$RecipientLimitExternalPerHour,

[Parameter()]
Expand Down Expand Up @@ -337,15 +337,15 @@ function Test-TargetResource
$NotifyOutboundSpam = $true,

[Parameter()]
[System.String]
[System.UInt32]
$RecipientLimitInternalPerHour,

[Parameter()]
[System.String]
[System.UInt32]
$RecipientLimitPerDay,

[Parameter()]
[System.String]
[System.UInt32]
$RecipientLimitExternalPerHour,

[Parameter()]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ class MSFT_EXOHostedOutboundSpamFilterPolicy : OMI_BaseResource
[Write, Description("The BccSuspiciousOutboundMail parameter enables or disables adding recipients to the Bcc field of outgoing spam messages. Valid input for this parameter is $true or $false. The default value is $false. You specify the additional recipients using the BccSuspiciousOutboundAdditionalRecipients parameter.")] Boolean BccSuspiciousOutboundMail;
[Write, Description("The NotifyOutboundSpam parameter enables or disables sending notification messages to administrators when an outgoing message is determined to be spam. Valid input for this parameter is $true or $false. The default value is $false. You specify the administrators to notify by using the NotifyOutboundSpamRecipients parameter.")] Boolean NotifyOutboundSpam;
[Write, Description("The NotifyOutboundSpamRecipients parameter specifies the administrators to notify when an outgoing message is determined to be spam. Valid input for this parameter is an email address. Separate multiple email addresses with commas.")] String NotifyOutboundSpamRecipients[];
[Write, Description("The RecipientLimitInternalPerHour parameter specifies the maximum number of internal recipients that a user can send to within an hour. A valid value is 0 to 10000. The default value is 0, which means the service defaults are used.")] String RecipientLimitInternalPerHour;
[Write, Description("The RecipientLimitPerDay parameter specifies the maximum number of recipients that a user can send to within a day. A valid value is 0 to 10000. The default value is 0, which means the service defaults are used.")] String RecipientLimitPerDay;
[Write, Description("The RecipientLimitExternalPerHour parameter specifies the maximum number of external recipients that a user can send to within an hour. A valid value is 0 to 10000. The default value is 0, which means the service defaults are used.")] String RecipientLimitExternalPerHour;
[Write, Description("The RecipientLimitInternalPerHour parameter specifies the maximum number of internal recipients that a user can send to within an hour. A valid value is 0 to 10000. The default value is 0, which means the service defaults are used.")] UInt32 RecipientLimitInternalPerHour;
[Write, Description("The RecipientLimitPerDay parameter specifies the maximum number of recipients that a user can send to within a day. A valid value is 0 to 10000. The default value is 0, which means the service defaults are used.")] UInt32 RecipientLimitPerDay;
[Write, Description("The RecipientLimitExternalPerHour parameter specifies the maximum number of external recipients that a user can send to within an hour. A valid value is 0 to 10000. The default value is 0, which means the service defaults are used.")] UInt32 RecipientLimitExternalPerHour;
[Write, Description("The ActionWhenThresholdReached parameter specifies the action to take when any of the limits specified in the policy are reached. Valid values are: Alert, BlockUser, BlockUserForToday. BlockUserForToday is the default value.")] String ActionWhenThresholdReached;
[Write, Description("The AutoForwardingMode specifies how the policy controls automatic email forwarding to outbound recipients. Valid values are: Automatic, On, Off.")] String AutoForwardingMode;
[Write, Description("Specify if this policy should exist or not."), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Configuration Example
)
Import-DscResource -ModuleName Microsoft365DSC

$Domain = $Credscredential.Username.Split('@')[1]
node localhost
{
EXODistributionGroup 'DemoDG'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Configuration Example
)
Import-DscResource -ModuleName Microsoft365DSC

$Domain = $Credscredential.Username.Split('@')[1]
node localhost
{
EXOEmailAddressPolicy 'ConfigureEmailAddressPolicy'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ Configuration Example
BccSuspiciousOutboundMail = $False
NotifyOutboundSpam = $False
NotifyOutboundSpamRecipients = @()
RecipientLimitExternalPerHour = 0
RecipientLimitInternalPerHour = 0
RecipientLimitPerDay = 0
#RecipientLimitExternalPerHour = 0
#RecipientLimitInternalPerHour = 0
#RecipientLimitPerDay = 0
Ensure = "Present"
ApplicationId = $ApplicationId
TenantId = $TenantId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ Configuration Example
BccSuspiciousOutboundMail = $False
NotifyOutboundSpam = $False
NotifyOutboundSpamRecipients = @()
RecipientLimitExternalPerHour = 0
RecipientLimitInternalPerHour = 1 # Updated Property
RecipientLimitPerDay = 0
#RecipientLimitExternalPerHour = 0
#RecipientLimitInternalPerHour = 1 # Updated Property
#RecipientLimitPerDay = 0
Ensure = "Present"
ApplicationId = $ApplicationId
TenantId = $TenantId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ Configuration Example

Import-DscResource -ModuleName Microsoft365DSC

$Domain = $Credscredential.Username.Split('@')[1]
node localhost
{
EXOHostedOutboundSpamFilterRule 'ConfigureHostedOutboundSpamFilterRule'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Configuration Example
)
Import-DscResource -ModuleName Microsoft365DSC

$Domain = $Credscredential.Username.Split('@')[1]
node localhost
{
EXOMailContact 'TestMailContact'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Configuration Example
)
Import-DscResource -ModuleName Microsoft365DSC

$Domain = $Credscredential.Username.Split('@')[1]
node localhost
{
EXOMailContact 'TestMailContact'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Configuration Example
)
Import-DscResource -ModuleName Microsoft365DSC

$Domain = $Credscredential.Username.Split('@')[1]
node localhost
{
EXOManagementRole 'ConfigureManagementRole'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Configuration Example
)
Import-DscResource -ModuleName Microsoft365DSC

$Domain = $Credscredential.Username.Split('@')[1]
node localhost
{
EXOManagementRoleAssignment 'AssignManagementRole'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Configuration Example
)
Import-DscResource -ModuleName Microsoft365DSC

$Domain = $Credscredential.Username.Split('@')[1]
node localhost
{
EXOManagementRoleAssignment 'AssignManagementRole'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Configuration Example
)
Import-DscResource -ModuleName Microsoft365DSC

$Domain = $Credscredential.Username.Split('@')[1]
node localhost
{
EXOManagementRoleAssignment 'AssignManagementRole'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Configuration Example
[System.String]
$CertificateThumbprint
)
$OrganizationName = $Credscredential.UserName.Split('@')[1]
Import-DscResource -ModuleName Microsoft365DSC

node localhost
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ Configuration Example
[System.String]
$CertificateThumbprint
)
$OrganizationName = $Credscredential.UserName.Split('@')[1]
Import-DscResource -ModuleName Microsoft365DSC

$Domain = $Credscredential.Username.Split('@')[1]
node localhost
{
EXOQuarantinePolicy 'ConfigureQuarantinePolicy'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ Configuration Example
[System.String]
$CertificateThumbprint
)
$OrganizationName = $Credscredential.UserName.Split('@')[1]
Import-DscResource -ModuleName Microsoft365DSC

$Domain = $Credscredential.Username.Split('@')[1]
node localhost
{
EXOQuarantinePolicy 'ConfigureQuarantinePolicy'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Configuration Example
)
Import-DscResource -ModuleName Microsoft365DSC

$Domain = $Credscredential.Username.Split('@')[1]
node localhost
{
EXOSafeAttachmentPolicy 'ConfigureSafeAttachmentPolicy'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Configuration Example
)
Import-DscResource -ModuleName Microsoft365DSC

$Domain = $Credscredential.Username.Split('@')[1]
node localhost
{
EXOSafeAttachmentPolicy 'ConfigureSafeAttachmentPolicy'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Configuration Example
)
Import-DscResource -ModuleName Microsoft365DSC

$Domain = $Credscredential.Username.Split('@')[1]
node localhost
{
EXOSafeAttachmentRule 'ConfigureSafeAttachmentRule'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Configuration Example
)
Import-DscResource -ModuleName Microsoft365DSC

$Domain = $Credscredential.Username.Split('@')[1]
node localhost
{
EXOSharedMailbox 'SharedMailbox'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Configuration Example
)
Import-DscResource -ModuleName Microsoft365DSC

$Domain = $Credscredential.Username.Split('@')[1]
node localhost
{
EXOTransportRule 'ConfigureTransportRule'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Configuration Example
)
Import-DscResource -ModuleName Microsoft365DSC

$Domain = $Credscredential.Username.Split('@')[1]
node localhost
{
EXOTransportRule 'ConfigureTransportRule'
Expand Down
4 changes: 4 additions & 0 deletions Tests/QA/Microsoft365DSC.Examples.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ Describe -Name 'Successfully compile examples' {
#>
$exampleParameters.Add($parameterName, ('1' -as $parameterType))
}
elseif ($parameterName -eq 'TenantId')
{
$exampleParameters.Add('TenantId', (New-Guid).ToString())
}
}
}

Expand Down

0 comments on commit 64bf481

Please sign in to comment.