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

ADReplicationSubnet: Add Integration Testing, Add Description #507

Merged
merged 33 commits into from
Sep 25, 2019
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
419c4a4
Checking in to switch dev machines
1800Zeta Sep 12, 2019
8dc90e7
Add description attribute to test-resource with unit tests
1800Zeta Sep 13, 2019
e4b255d
Add Description to Set-TargetResource
1800Zeta Sep 13, 2019
dbb48d0
Update test to increase codecov
1800Zeta Sep 13, 2019
de1cbba
Added Integration Testing
1800Zeta Sep 13, 2019
f1fd66d
Update Help Text and a small tidy up
1800Zeta Sep 13, 2019
55b0c3d
Update CHANGELOG.md
1800Zeta Sep 13, 2019
ee8dbe9
Update MSFT_ADReplicationSite.Tests.ps1
1800Zeta Sep 13, 2019
07933f2
Updates based on review
1800Zeta Sep 16, 2019
823a1c5
Set RenameDefaultFirstSiteName to false by default
1800Zeta Sep 16, 2019
915f6cc
Add Integration Tests
1800Zeta Sep 16, 2019
72ed5ad
Update MSFT_ADReplicationSubnet.config.ps1
1800Zeta Sep 16, 2019
bd998a4
Adding Description to ADReplicationSubnet
1800Zeta Sep 16, 2019
6c4e355
Update changelog and example
1800Zeta Sep 16, 2019
ff0629a
Update CHANGELOG.md
1800Zeta Sep 16, 2019
bc5dd69
Feedback request Pt2
1800Zeta Sep 18, 2019
83b8971
Remove extra parentheses as requested
1800Zeta Sep 18, 2019
9daa430
Merge branch 'dev' into dev
1800Zeta Sep 19, 2019
dca6684
Merge branch 'dev' into ADReplicationSubnet
1800Zeta Sep 19, 2019
0f38b6c
Update CHANGELOG.md
1800Zeta Sep 20, 2019
36acb70
Update CHANGELOG.md
1800Zeta Sep 20, 2019
2823f32
Blank Line under Unreleased header
1800Zeta Sep 20, 2019
458047e
Merge branch 'dev' into ADReplicationSubnet
jouzu-mark Sep 21, 2019
c57fde7
Merge branch 'dev' into ADReplicationSubnet
1800Zeta Sep 21, 2019
db55c92
Merge branch 'dev' into ADReplicationSubnet
1800Zeta Sep 21, 2019
08c87db
Update CHANGELOG.md
1800Zeta Sep 23, 2019
5ccb798
Additional test to ensure empty location string changes to $null
1800Zeta Sep 23, 2019
7db45ad
Update about_ADReplicationSubnet.help.txt
1800Zeta Sep 23, 2019
c1dcfec
Merge remote-tracking branch 'upstream/dev' into dev
1800Zeta Sep 24, 2019
0aa4351
Merge branch 'dev' into ADReplicationSubnet
1800Zeta Sep 24, 2019
cd28bd6
Feedback update
1800Zeta Sep 25, 2019
ed1a23a
Added Pre-Req Config. Changed name of config to Integration_Test
1800Zeta Sep 25, 2019
4546d43
Update MSFT_ADReplicationSubnet.config.ps1
1800Zeta Sep 25, 2019
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 @@ -8,6 +8,9 @@
- Added 'Description' attribute parameter ([issue #500](https://github.com/PowerShell/ActiveDirectoryDsc/issues/500)).
- Added Integration testing ([issue #355](https://github.com/PowerShell/ActiveDirectoryDsc/issues/355)).
- Correct value returned for RenameDefaultFirstSiteName ([issue #502](https://github.com/PowerShell/ActiveDirectoryDsc/issues/502)).
- Changes to ADReplicationSubnet
- Added 'Description' attribute parameter ([issue #503](https://github.com/PowerShell/ActiveDirectoryDsc/issues/500))
- Added Integration testing ([issue #357](https://github.com/PowerShell/ActiveDirectoryDsc/issues/357))

## 4.1.0.0

Expand Down
48 changes: 36 additions & 12 deletions DSCResources/MSFT_ADReplicationSubnet/MSFT_ADReplicationSubnet.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,19 @@ function Get-TargetResource
#>
Write-Verbose -Message ($script:localizedData.GetReplicationSubnet -f $Name)

$replicationSubnet = Get-ADReplicationSubnet -Filter { Name -eq $Name }
$replicationSubnet = Get-ADReplicationSubnet -Filter { Name -eq $Name } -Properties Description

if ($null -eq $replicationSubnet)
{
# Replication subnet not found, return absent.
Write-Verbose -Message ($script:localizedData.ReplicationSubnetAbsent -f $Name)

$returnValue = @{
Ensure = 'Absent'
Name = $Name
Site = ''
Location = ''
Ensure = 'Absent'
Name = $Name
Site = ''
Location = $null
Description = $null
}
}
else
Expand All @@ -68,10 +69,11 @@ function Get-TargetResource
Write-Verbose -Message ($script:localizedData.ReplicationSubnetPresent -f $Name)

$returnValue = @{
Ensure = 'Present'
Name = $Name
Site = $replicationSiteName
Location = [System.String] $replicationSubnet.Location
Ensure = 'Present'
Name = $Name
Site = $replicationSiteName
Location = [System.String] $replicationSubnet.Location
Description = [System.String] $replicationSubnet.Description
}
}

Expand Down Expand Up @@ -116,7 +118,11 @@ function Set-TargetResource

[Parameter()]
[System.String]
$Location = ''
$Location = '',

[Parameter()]
[System.String]
$Description
)

<#
Expand Down Expand Up @@ -169,6 +175,16 @@ function Set-TargetResource

Set-ADReplicationSubnet -Identity $replicationSubnet.DistinguishedName -Location $nullableLocation -PassThru
}

if ($PSBoundParameters.ContainsKey('Description'))
{
if ($replicationSubnet.Description -ne $Description)
{
Write-Verbose -Message ($script:localizedData.SetReplicationSubnetDescription -f $Name, $Description)

Set-ADReplicationSubnet -Identity $replicationSubnet.DistinguishedName -Description $Description
}
}
}

if ($Ensure -eq 'Absent')
Expand Down Expand Up @@ -198,6 +214,9 @@ function Set-TargetResource

.PARAMETER Location
The location for the AD replication site. Default value is empty.

.PARAMETER Description
Specifies a description of the object. This parameter sets the value of the Description property for the object.
#>
function Test-TargetResource
{
Expand All @@ -222,7 +241,11 @@ function Test-TargetResource

[Parameter()]
[System.String]
$Location = ''
$Location = '',

[Parameter()]
[System.String]
$Description
)

$currentConfiguration = Get-TargetResource -Name $Name -Site $Site
Expand All @@ -233,7 +256,8 @@ function Test-TargetResource
{
$desiredConfigurationMatch = $desiredConfigurationMatch -and
$currentConfiguration.Site -eq $Site -and
$currentConfiguration.Location -eq $Location
$currentConfiguration.Location -eq $Location -and
$currentConfiguration.Description -eq $Description
}

if ($desiredConfigurationMatch)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ class MSFT_ADReplicationSubnet : OMI_BaseResource
[Key, Description("The name of the Active Directory replication subnet, e.g. 10.0.0.0/24.")] String Name;
[Required, Description("The name of the assigned Active Directory replication site, e.g. Default-First-Site-Name.")] String Site;
[Write, Description("The location for the Active Directory replication site. Default value is empty ('') location.")] String Location;
[Write, Description("Specifies a description of the object. This parameter sets the value of the Description property for the object.")] String Description;
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ ConvertFrom-StringData @'
ReplicationSubnetPresent = Replication subnet '{0}' is present. (ADRS0007)
ReplicationSubnetInDesiredState = The replication subnet '{0}' is in the desired state. (ADRS0008)
ReplicationSubnetNotInDesiredState = The replication subnet '{0}' is not in the desired state. (ADRS0009)
SetReplicationSubnetDescription = Set the replication subnet '{0}' description to '{1}'. (ADRS0010)
'@
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
Write - String
The location for the Active Directory replication site. Default value is empty ('') location.

.PARAMETER Description
Write - String
Specifies a description of the object. This parameter sets the value of the Description property for the object.

.EXAMPLE 1

This configuration will create an AD Replication Subnet.
Expand All @@ -37,9 +41,10 @@ Configuration ADReplicationSubnet_CreateReplicationSubnet_Config
{
ADReplicationSubnet 'LondonSubnet'
{
Name = '10.0.0.0/24'
Site = 'London'
Location = 'Datacenter 3'
Name = '10.0.0.0/24'
Site = 'London'
Location = 'Datacenter 3'
Description = 'Datacenter Management Subnet'
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ Configuration ADReplicationSubnet_CreateReplicationSubnet_Config
{
ADReplicationSubnet 'LondonSubnet'
{
Name = '10.0.0.0/24'
Site = 'London'
Location = 'Datacenter 3'
Name = '10.0.0.0/24'
Site = 'London'
Location = 'Datacenter 3'
Description = 'Datacenter Management Subnet'
}
}
}
Loading