-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from PlagueHO/Support-v4-and-v6-DNS-Per-Interface
Added support for setting DNS for both IPv4 and IPv6 on the same Interface
- Loading branch information
Showing
4 changed files
with
120 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 7 additions & 7 deletions
14
DSCResources/MSFT_xDNSServerAddress/MSFT_xDNSServerAddress.schema.mof
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
[ClassVersion("1.0.0"), FriendlyName("xDNSServerAddress")] | ||
class MSFT_xDNSServerAddress : OMI_BaseResource | ||
{ | ||
[Required] string Address[]; | ||
[Key] string InterfaceAlias; | ||
[Write,ValueMap{"IPv4", "IPv6"},Values{"IPv4", "IPv6"}] string AddressFamily; | ||
}; | ||
[ClassVersion("1.0.0"), FriendlyName("xDNSServerAddress")] | ||
class MSFT_xDNSServerAddress : OMI_BaseResource | ||
{ | ||
[Required] string Address[]; | ||
[Key] string InterfaceAlias; | ||
[Key,Write,ValueMap{"IPv4", "IPv6"},Values{"IPv4", "IPv6"}] string AddressFamily; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
$here = Split-Path -Parent $MyInvocation.MyCommand.Path | ||
|
||
if (Get-Module MSFT_xDNSServerAddress -All) | ||
{ | ||
Get-Module MSFT_xDNSServerAddress -All | Remove-Module | ||
} | ||
|
||
Import-Module -Name $PSScriptRoot\..\DSCResources\MSFT_xDNSServerAddress -Force -DisableNameChecking | ||
|
||
InModuleScope MSFT_xDNSServerAddress { | ||
|
||
Describe 'Get-TargetResource' { | ||
|
||
#region Mocks | ||
Mock Get-DnsClientServerAddress -MockWith { | ||
|
||
[PSCustomObject]@{ | ||
ServerAddresses = '192.168.0.1' | ||
InterfaceAlias = 'Ethernet' | ||
AddressFamily = 'IPv4' | ||
} | ||
} | ||
#endregion | ||
|
||
Context 'comparing IPAddress' { | ||
It 'should return true' { | ||
|
||
$Splat = @{ | ||
Address = '192.168.0.1' | ||
InterfaceAlias = 'Ethernet' | ||
AddressFamily = 'IPv4' | ||
} | ||
$Result = Get-TargetResource @Splat | ||
$Result.IPAddress | Should Be $Splat.IPAddress | ||
} | ||
} | ||
} | ||
|
||
|
||
Describe 'ValidateProperties' { | ||
|
||
#region Mocks | ||
Mock Get-DnsClientServerAddress -MockWith { | ||
|
||
[PSCustomObject]@{ | ||
ServerAddresses = '192.168.0.1' | ||
InterfaceAlias = 'Ethernet' | ||
AddressFamily = 'IPv4' | ||
} | ||
} | ||
|
||
Mock Set-DnsClientServerAddress -MockWith {} | ||
#endregion | ||
|
||
Context 'invoking without -Apply switch' { | ||
|
||
It 'should be $false' { | ||
$Splat = @{ | ||
Address = '10.0.0.2' | ||
InterfaceAlias = 'Ethernet' | ||
AddressFamily = 'IPv4' | ||
} | ||
$Result = ValidateProperties @Splat | ||
$Result | Should Be $false | ||
} | ||
|
||
It 'should be $true' { | ||
$Splat = @{ | ||
Address = '192.168.0.1' | ||
InterfaceAlias = 'Ethernet' | ||
AddressFamily = 'IPv4' | ||
} | ||
$Result = ValidateProperties @Splat | ||
$Result | Should Be $true | ||
} | ||
|
||
It 'should call Get-DnsClientServerAddress once' { | ||
Assert-MockCalled -commandName Get-DnsClientServerAddress | ||
} | ||
} | ||
|
||
Context 'invoking with -Apply switch' { | ||
|
||
It 'should be $null' { | ||
$Splat = @{ | ||
Address = '10.0.0.2' | ||
InterfaceAlias = 'Ethernet' | ||
AddressFamily = 'IPv4' | ||
} | ||
$Result = ValidateProperties @Splat -Apply | ||
$Result | Should BeNullOrEmpty | ||
} | ||
|
||
It 'should call all the mocks' { | ||
Assert-MockCalled -commandName Get-DnsClientServerAddress | ||
Assert-MockCalled -commandName Set-DnsClientServerAddress | ||
} | ||
} | ||
} | ||
} |