forked from jpogran/PuppetDscBuilder
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
11 changed files
with
77 additions
and
12 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
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
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
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
34 changes: 34 additions & 0 deletions
34
src/internal/functions/Test-DscResourcePropertyParameterStatus.ps1
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,34 @@ | ||
Function Test-DscResourcePropertyParameterStatus { | ||
<# | ||
.SYNOPSIS | ||
Return whether or not a DSC Resource Property can be read from a target system | ||
.DESCRIPTION | ||
Some DSC Resources have properties which cannot be read back from a target system | ||
with the Get method. These properties are classified as parameters in Puppet. | ||
.PARAMETER Property | ||
The DSC Resource property to check for parameter status | ||
.EXAMPLE | ||
Test-DscResourcePropertyParameterStatus -Property $DscResource.Properties[0] | ||
This will return `$True` if the property is a parameter and `$False` otherwise. | ||
#> | ||
[cmdletbinding()] | ||
[OutputType([Boolean])] | ||
Param( | ||
# We cannot strongly type this *and* have useful unit tests as the type | ||
# has read-only values and cannot be created properly nor updated. For | ||
# other commands we could just grab real examples but for processing a | ||
# ton of data types, that's just not feasible. It *should* be: | ||
# Microsoft.PowerShell.DesiredStateConfiguration.DscResourcePropertyInfo | ||
[ValidateNotNullOrEmpty()] | ||
$Property | ||
) | ||
|
||
$KnownParameters = @( | ||
'Force' | ||
'Purge' | ||
'Validate' | ||
) | ||
|
||
$Property.Name -in $KnownParameters -or $Property.ReferenceClassName -match 'Credential' | ||
} |
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
28 changes: 28 additions & 0 deletions
28
src/tests/functions/Test-DscResourcePropertyParameterStatus.Tests.ps1
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,28 @@ | ||
Describe 'Test-SymLinkedItem' { | ||
InModuleScope puppet.dsc { | ||
Context 'Basic verification' { | ||
Function New-DscParameter { | ||
Param ( | ||
[string]$Name = 'foo', | ||
[string]$ReferenceClassName | ||
) | ||
[pscustomobject]@{ | ||
Name = $Name | ||
ReferenceClassName = $ReferenceClassName | ||
} | ||
} | ||
|
||
It 'A parameter which is not in the known parameter list or a credential returns false' { | ||
Test-DscResourcePropertyParameterStatus -Property (New-DscParameter) | Should -Be $false | ||
} | ||
It 'A parameter whose name is in the known parameter list returns true' { | ||
Test-DscResourcePropertyParameterStatus -Property (New-DscParameter -Name 'Force') | Should -Be $true | ||
Test-DscResourcePropertyParameterStatus -Property (New-DscParameter -Name 'Purge') | Should -Be $true | ||
Test-DscResourcePropertyParameterStatus -Property (New-DscParameter -Name 'Validate') | Should -Be $true | ||
} | ||
It 'A parameter whose reference class is a credential returns true' { | ||
Test-DscResourcePropertyParameterStatus -Property (New-DscParameter -ReferenceClassName 'MSFT_Credential') | Should -Be $true | ||
} | ||
} | ||
} | ||
} |