Skip to content

Commit

Permalink
xDnsServerZoneAging: Added integration tests (#187)
Browse files Browse the repository at this point in the history
- xDnsServerZoneAging
  - Added integration tests (issue #176).
  • Loading branch information
johlju authored Feb 28, 2021
1 parent 8c9de2b commit 56f39a6
Show file tree
Hide file tree
Showing 4 changed files with 348 additions and 11 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added more examples.
- xDnsRecordMx
- Added new resource to manage MX records
- xDnsServerZoneAging
- Added integration tests ([issue #176](https://github.com/dsccommunity/xDnsServer/issues/176)).
- xDnsServerForwarder
- Added integration test ([issue #170](https://github.com/dsccommunity/xDnsServer/issues/170)).
- Added integration tests ([issue #170](https://github.com/dsccommunity/xDnsServer/issues/170)).
- xDnsServerRootHint
- Added integration test ([issue #174](https://github.com/dsccommunity/xDnsServer/issues/174)).
- Added integration tests ([issue #174](https://github.com/dsccommunity/xDnsServer/issues/174)).

### Changed

Expand Down
18 changes: 9 additions & 9 deletions tests/Integration/MSFT_xDnsServerPrimaryZone.config.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ $ConfigurationData = @{
ClassfulReverseZoneDynamicUpdate = 'NonSecureAndSecure'

# Classless reverse zone
ClasslessReverseZoneName = '64-26.100.168.192.in-addr.arpa'
ClasslessReverseZoneName = '64-26.100.168.192.in-addr.arpa'
}
)
}
Expand All @@ -38,7 +38,7 @@ configuration MSFT_xDnsServerPrimaryZone_AddForwardZoneUsingDefaultValues_Config
{
xDnsServerPrimaryZone 'Integration_Test'
{
Name = $Node.ForwardZoneName
Name = $Node.ForwardZoneName
}
}
}
Expand All @@ -59,8 +59,8 @@ configuration MSFT_xDnsServerPrimaryZone_RemoveForwardZone_Config
{
xDnsServerPrimaryZone 'Integration_Test'
{
Ensure = 'Absent'
Name = $Node.ForwardZoneName
Ensure = 'Absent'
Name = $Node.ForwardZoneName
}
}
}
Expand Down Expand Up @@ -119,8 +119,8 @@ configuration MSFT_xDnsServerPrimaryZone_RemoveClassfulReverseZone_Config
{
xDnsServerPrimaryZone 'Integration_Test'
{
Ensure = 'Absent'
Name = $Node.ClassfulReverseZoneName
Ensure = 'Absent'
Name = $Node.ClassfulReverseZoneName
}
}
}
Expand All @@ -137,7 +137,7 @@ configuration MSFT_xDnsServerPrimaryZone_AddClasslessReverseZone_Config
{
xDnsServerPrimaryZone 'Integration_Test'
{
Name = $Node.ClasslessReverseZoneName
Name = $Node.ClasslessReverseZoneName
}
}
}
Expand All @@ -155,8 +155,8 @@ configuration MSFT_xDnsServerPrimaryZone_RemoveClasslessReverseZone_Config
{
xDnsServerPrimaryZone 'Integration_Test'
{
Ensure = 'Absent'
Name = $Node.ClasslessReverseZoneName
Ensure = 'Absent'
Name = $Node.ClasslessReverseZoneName
}
}
}
240 changes: 240 additions & 0 deletions tests/Integration/MSFT_xDnsServerZoneAging.Integration.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,240 @@
$script:dscModuleName = 'xDnsServer'
$script:dscResourceFriendlyName = 'xDnsServerZoneAging'
$script:dscResourceName = "MSFT_$($script:dscResourceFriendlyName)"

try
{
Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop'
}
catch [System.IO.FileNotFoundException]
{
throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.'
}

$script:testEnvironment = Initialize-TestEnvironment `
-DSCModuleName $script:dscModuleName `
-DSCResourceName $script:dscResourceName `
-ResourceType 'Mof' `
-TestType 'Integration'

try
{
$configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1"
. $configFile

Describe "$($script:dscResourceName)_Integration" {
BeforeAll {
$resourceId = "[$($script:dscResourceFriendlyName)]Integration_Test"
}

$configurationName = "$($script:dscResourceName)_Prerequisites_Config"

Context ('When using configuration {0}' -f $configurationName) {
It 'Should compile and apply the MOF without throwing' {
{
$configurationParameters = @{
OutputPath = $TestDrive
ConfigurationData = $ConfigurationData
}

& $configurationName @configurationParameters

$startDscConfigurationParameters = @{
Path = $TestDrive
ComputerName = 'localhost'
Wait = $true
Verbose = $true
Force = $true
ErrorAction = 'Stop'
}

Start-DscConfiguration @startDscConfigurationParameters
} | Should -Not -Throw
}
}

Wait-ForIdleLcm -Clear

$configurationName = "$($script:dscResourceName)_ForwardZone_Config"

Context ('When using configuration {0}' -f $configurationName) {
It 'Should compile and apply the MOF without throwing' {
{
$configurationParameters = @{
OutputPath = $TestDrive
ConfigurationData = $ConfigurationData
}

& $configurationName @configurationParameters

$startDscConfigurationParameters = @{
Path = $TestDrive
ComputerName = 'localhost'
Wait = $true
Verbose = $true
Force = $true
ErrorAction = 'Stop'
}

Start-DscConfiguration @startDscConfigurationParameters
} | Should -Not -Throw
}

It 'Should be able to call Get-DscConfiguration without throwing' {
{
$script:currentConfiguration = Get-DscConfiguration -Verbose -ErrorAction Stop
} | Should -Not -Throw
}

It 'Should have set the resource and all the parameters should match' {
$resourceCurrentState = $script:currentConfiguration | Where-Object -FilterScript {
$_.ConfigurationName -eq $configurationName `
-and $_.ResourceId -eq $resourceId
}

$resourceCurrentState.Name | Should -Be $ConfigurationData.AllNodes.ForwardZoneName
$resourceCurrentState.Enabled | Should -BeTrue
$resourceCurrentState.RefreshInterval | Should -Be 240
$resourceCurrentState.NoRefreshInterval | Should -Be 480
}

It 'Should return ''True'' when Test-DscConfiguration is run' {
Test-DscConfiguration -Verbose | Should -Be 'True'
}
}

Wait-ForIdleLcm -Clear

$configurationName = "$($script:dscResourceName)_ForwardZoneDisableAging_Config"

Context ('When using configuration {0}' -f $configurationName) {
It 'Should compile and apply the MOF without throwing' {
{
$configurationParameters = @{
OutputPath = $TestDrive
ConfigurationData = $ConfigurationData
}

& $configurationName @configurationParameters

$startDscConfigurationParameters = @{
Path = $TestDrive
ComputerName = 'localhost'
Wait = $true
Verbose = $true
Force = $true
ErrorAction = 'Stop'
}

Start-DscConfiguration @startDscConfigurationParameters
} | Should -Not -Throw
}

It 'Should be able to call Get-DscConfiguration without throwing' {
{
$script:currentConfiguration = Get-DscConfiguration -Verbose -ErrorAction Stop
} | Should -Not -Throw
}

It 'Should have set the resource and all the parameters should match' {
$resourceCurrentState = $script:currentConfiguration | Where-Object -FilterScript {
$_.ConfigurationName -eq $configurationName `
-and $_.ResourceId -eq $resourceId
}

$resourceCurrentState.Name | Should -Be $ConfigurationData.AllNodes.ForwardZoneName
$resourceCurrentState.Enabled | Should -BeFalse
$resourceCurrentState.RefreshInterval | Should -Be 240
$resourceCurrentState.NoRefreshInterval | Should -Be 480
}

It 'Should return ''True'' when Test-DscConfiguration is run' {
Test-DscConfiguration -Verbose | Should -Be 'True'
}
}

Wait-ForIdleLcm -Clear

$configurationName = "$($script:dscResourceName)_ReverseZone_Config"

Context ('When using configuration {0}' -f $configurationName) {
It 'Should compile and apply the MOF without throwing' {
{
$configurationParameters = @{
OutputPath = $TestDrive
ConfigurationData = $ConfigurationData
}

& $configurationName @configurationParameters

$startDscConfigurationParameters = @{
Path = $TestDrive
ComputerName = 'localhost'
Wait = $true
Verbose = $true
Force = $true
ErrorAction = 'Stop'
}

Start-DscConfiguration @startDscConfigurationParameters
} | Should -Not -Throw
}

It 'Should be able to call Get-DscConfiguration without throwing' {
{
$script:currentConfiguration = Get-DscConfiguration -Verbose -ErrorAction Stop
} | Should -Not -Throw
}

It 'Should have set the resource and all the parameters should match' {
$resourceCurrentState = $script:currentConfiguration | Where-Object -FilterScript {
$_.ConfigurationName -eq $configurationName `
-and $_.ResourceId -eq $resourceId
}

$resourceCurrentState.Name | Should -Be $ConfigurationData.AllNodes.ReverseZoneName
$resourceCurrentState.Enabled | Should -BeFalse
$resourceCurrentState.RefreshInterval | Should -Be 250
$resourceCurrentState.NoRefreshInterval | Should -Be 490
}

It 'Should return ''True'' when Test-DscConfiguration is run' {
Test-DscConfiguration -Verbose | Should -Be 'True'
}
}

Wait-ForIdleLcm -Clear

$configurationName = "$($script:dscResourceName)_Cleanup_Config"

Context ('When using configuration {0}' -f $configurationName) {
It 'Should compile and apply the MOF without throwing' {
{
$configurationParameters = @{
OutputPath = $TestDrive
ConfigurationData = $ConfigurationData
}

& $configurationName @configurationParameters

$startDscConfigurationParameters = @{
Path = $TestDrive
ComputerName = 'localhost'
Wait = $true
Verbose = $true
Force = $true
ErrorAction = 'Stop'
}

Start-DscConfiguration @startDscConfigurationParameters
} | Should -Not -Throw
}
}

Wait-ForIdleLcm -Clear
}
}
finally
{
Restore-TestEnvironment -TestEnvironment $script:testEnvironment
}
Loading

0 comments on commit 56f39a6

Please sign in to comment.