Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADDomainController: Fix Test-TargetResource Issue When the 'ReadOnlyReplica' Property is set to 'true' #615

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ For older change log history see the [historic changelog](HISTORIC_CHANGELOG.md)
- Restored importing the `DscResource.Common` module import in the `ActiveDirectoryDsc.Common` module that was
incorrectly disabled.
([issue #612](https://github.com/dsccommunity/ActiveDirectoryDsc/issues/612)).
- ADDomainController
- Fixed `Test-TargetResource` error when the `ReadOnlyReplica` property is set to `true`
([issue #611](https://github.com/dsccommunity/ActiveDirectoryDsc/issues/611)).
- ADReplicationSiteLink
- Fixed setting options after the resource is initially created
([issue #605](https://github.com/dsccommunity/ActiveDirectoryDsc/issues/605)).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ function Test-TargetResource

if ($PSBoundParameters.ContainsKey('ReadOnlyReplica') -and $ReadOnlyReplica)
{
if ($testTargetResourceReturnValue -and -not $testTargetResourceReturnValue.ReadOnlyReplica)
if ($testTargetResourceReturnValue -and -not $existingResource.ReadOnlyReplica)
{
New-InvalidOperationException -Message $script:localizedData.CannotConvertToRODC
}
Expand Down
13 changes: 13 additions & 0 deletions tests/Unit/MSFT_ADDomainController.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ try
AllowPasswordReplicationAccountName = @($allowedAccount)
DenyPasswordReplicationAccountName = @($deniedAccount)
FlexibleSingleMasterOperationRole = @('DomainNamingMaster', 'RIDMaster')
ReadOnlyReplica = $true
Ensure = $true
}
}
Expand Down Expand Up @@ -452,6 +453,18 @@ try
Assert-MockCalled -CommandName Get-TargetResource -Exactly -Times 1
}
}

Context 'When property ReadOnlyReplica and SiteName are in desired state' {
It 'Should return $true' {
$result = Test-TargetResource @testDefaultParams -DomainName $correctDomainName `
-ReadOnlyReplica $true -SiteName $correctSiteName
$result | Should -Be $true
}

It 'Should call the expected mocks' {
Assert-MockCalled -CommandName Get-TargetResource -Exactly -Times 1
}
}
}

Context 'When the system is not in the desired state' {
Expand Down