Skip to content

Commit eb73629

Browse files
author
Andrew
committed
update 4
1 parent 238bd9a commit eb73629

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

powershell-adapter/Tests/TestClassResource/0.0.1/TestClassResource.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class TestClassResource : BaseTestClass
3333

3434
hidden
3535
[DscProperty()]
36-
[string] $HiddenDscProperty
36+
[string] $HiddenDscProperty # This property should be in results data, but is an anti-pattern.
3737

3838
[void] Set()
3939
{

powershell-adapter/Tests/powershellgroup.resource.tests.ps1

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ Describe 'PowerShell adapter resource tests' {
3737
$LASTEXITCODE | Should -Be 0
3838
$res = $r | ConvertFrom-Json
3939
$res.actualState.result.properties.Prop1 | Should -BeExactly 'ValueForProp1'
40+
41+
# verify that only properties with DscProperty attribute are returned
42+
$propertiesNames = $res.actualState.result.properties | Get-Member -MemberType NoteProperty | % Name
43+
$propertiesNames | Should -Not -Contain 'NonDscProperty'
44+
$propertiesNames | Should -Not -Contain 'HiddenNonDscProperty'
4045
}
4146

4247
It 'Get uses enum names on class-based resource' {
@@ -53,6 +58,11 @@ Describe 'PowerShell adapter resource tests' {
5358
$LASTEXITCODE | Should -Be 0
5459
$res = $r | ConvertFrom-Json
5560
$res.actualState.result.properties.InDesiredState | Should -Be $True
61+
62+
# verify that only properties with DscProperty attribute are returned
63+
$propertiesNames = $res.actualState.result.properties.InDesiredState | Get-Member -MemberType NoteProperty | % Name
64+
$propertiesNames | Should -Not -Contain 'NonDscProperty'
65+
$propertiesNames | Should -Not -Contain 'HiddenNonDscProperty'
5666
}
5767

5868
It 'Set works on class-based resource' {
@@ -71,6 +81,13 @@ Describe 'PowerShell adapter resource tests' {
7181
$res.resources[0].properties.result.count | Should -Be 5
7282
$res.resources[0].properties.result[0].Name | Should -Be "Object1"
7383
$res.resources[0].properties.result[0].Prop1 | Should -Be "Property of object1"
84+
85+
# verify that only properties with DscProperty attribute are returned
86+
$res.resources[0].properties.result | %{
87+
$propertiesNames = $_ | Get-Member -MemberType NoteProperty | % Name
88+
$propertiesNames | Should -Not -Contain 'NonDscProperty'
89+
$propertiesNames | Should -Not -Contain 'HiddenNonDscProperty'
90+
}
7491
}
7592

7693
It 'Get --all works on PS class-based resource' {

0 commit comments

Comments
 (0)