Skip to content

Commit

Permalink
fixing some of the pester tests and the helper module.
Browse files Browse the repository at this point in the history
  • Loading branch information
Svilen authored and SSvilen committed Apr 18, 2020
1 parent 7ac7480 commit cbe6efc
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ function Set-TargetResource
ExtendedRightDenyEntries = $ExtendedRightDenyEntries
DomainController = $DomainController
Identity = $Identity.Split('\')[1]
NewObject = $false
}

Set-ADExtendedPermissions @splat
Expand Down
3 changes: 2 additions & 1 deletion source/Modules/xExchangeHelper/xExchangeHelper.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@
'Set-DSCMachineStatus',
'Test-ExtendedRightsPresent',
'Test-ExtendedRights',
'Get-ADExtendedPermissions'
'Get-ADExtendedPermissions',
'Set-ADExtendedPermissions'
)

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
Expand Down
1 change: 1 addition & 0 deletions source/Modules/xExchangeHelper/xExchangeHelper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -2799,6 +2799,7 @@ function Set-ADExtendedPermissions
{
[CmdletBinding()]
param (
[Parameter()]
[Microsoft.Management.Infrastructure.CimInstance[]]
$ExtendedRightAllowEntries = @(),

Expand Down
10 changes: 1 addition & 9 deletions tests/Unit/MSFT_xExchReceiveConnector.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -241,15 +241,7 @@ try
value = 'ms-Exch-SMTP-Accept-Any-Recipient,ms-Exch-SMTP-Accept-Any-Sender'
} -ClientOnly

Mock -CommandName 'Get-ADPermission' -Verifiable -ParameterFilter { $Identity -eq 'ReceiveConnector' } -MockWith {
return $setTargetResourcePermissions['ExtendedRightAllowEntries']
}
Mock -CommandName 'Add-ADPermission' -Verifiable -ParameterFilter {
$Identity -eq 'ReceiveConnector' -and
$User -eq 'User1Allow' -and
($ExtendedRights -eq 'ms-Exch-SMTP-Accept-Any-Recipient' -or
$ExtendedRights -eq 'ms-Exch-SMTP-Accept-Any-Sender')
}
Mock -CommandName 'Set-ADExtendedPermissions ' -Verifiable -ParameterFilter { $Identity -eq 'ReceiveConnector'}

Set-TargetResource @setTargetResourcePermissions
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/xExchangeHelper.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3164,7 +3164,7 @@ try
It 'Should throw when the object is not found' {
Mock -CommandName 'Get-ADPermission' -Verifiable -ParameterFilter { $Identity -eq 'FakeADObject' }

& { Set-ADExtendedPermissions -Identity 'FakeADobject' -NewObject } | Should -Throw "The AD Object $Identity was not found after 2 minutes of wait time. Please check AD replication!"
{ Set-ADExtendedPermissions -Identity 'FakeADobject' -NewObject } | Should -Throw "The AD Object $Identity was not found after 2 minutes of wait time. Please check AD replication!"
}
It 'Should set the allow Permissions when specified' {
$ExtendedRightAllowEntries = New-CimInstance -ClassName MSFT_KeyValuePair -Property @{
Expand Down

0 comments on commit cbe6efc

Please sign in to comment.