Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
oliveirt committed Feb 3, 2020
1 parent 640f243 commit 7c487ca
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ For older change log history see the [historic changelog](HISTORIC_CHANGELOG.md)
- Fixed ability to clear `ServicePrincipalNameSuffix` and `UserPrincipalNameSuffix` ([issue #548](https://github.com/PowerShell/ActiveDirectoryDsc/issues/548)).
- ADObjectPermissionEntry
- Fixed issue where Get-DscConfiguration / Test-DscConfiguration throw an exception when target object path does not yet exist ([issue #552](https://github.com/dsccommunity/ActiveDirectoryDsc/issues/552))
- ADOrganizationalUnit
- Fixed issue where Get-DscConfiguration / Test-DscConfiguration throw an exception when parent path does not yet exist ([issue #553](https://github.com/dsccommunity/ActiveDirectoryDsc/issues/553))

### Changed

Expand Down
8 changes: 4 additions & 4 deletions Tests/Unit/MSFT_ADOrganizationalUnit.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ try
$targetResource.Description | Should -BeNullOrEmpty
}

It 'Should throw the correct error if the path does not exist' {
It 'Returns "Ensure" = "Absent" when OU parent path does not exist and does not throw an exception' {
Mock -CommandName Assert-Module
Mock -CommandName Get-ADOrganizationalUnit -MockWith { throw New-Object Microsoft.ActiveDirectory.Management.ADIdentityNotFoundException }

$errorMessage = $script:localizedData.PathNotFoundError -f $testPresentParams.Path
{ Get-TargetResource -Name $testPresentParams.Name -Path $testPresentParams.Path } | Should -Throw $errorMessage
$targetResource = Get-TargetResource -Name $testPresentParams.Name -Path $testPresentParams.Path
$targetResource.Ensure | Should -Be 'Absent'
}

It 'Should throw the correct error if an unkwon error occurs' {
It 'Should throw the correct error if an unknown error occurs' {
$error = 'Unknown Error'
Mock -CommandName Assert-Module
Mock -CommandName Get-ADOrganizationalUnit -MockWith { throw $error }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ function Get-TargetResource
}
catch [Microsoft.ActiveDirectory.Management.ADIdentityNotFoundException]
{
$errorMessage = $script:localizedData.PathNotFoundError -f $Path
New-ObjectNotFoundException -Message $errorMessage
Write-Verbose -Message ($script:localizedData.OUPathIsAbsent -f $Path)
}
catch
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ ConvertFrom-StringData @'
OUExistsButShouldNot = OU '{0}' exists when it should not exist. (ADOU0008)
OUDoesNotExistButShould = OU '{0}' does not exist when it should exist. (ADOU0009)
OUDoesNotExistAndShouldNot = OU '{0}' does not exist and is in the desired state. (ADOU0010)
PathNotFoundError = The Path '{0}' was not found. (ADOU0011)
OUPathIsAbsent = The OU Path '{0}' is absent from Active Directory. (ADOU0011)
'@

0 comments on commit 7c487ca

Please sign in to comment.