@@ -274,26 +274,61 @@ Describe 'Parameters tests' {
274
274
$out.results [0 ].result.inDesiredState | Should - BeTrue
275
275
}
276
276
277
- It ' secure types can be passed as objects to resources but redacted in output' {
278
- $out = dsc - l trace config -f $PSScriptRoot / ../ examples/ secure_parameters.parameters.yaml get -f $PSScriptRoot / ../ examples/ secure_parameters.dsc.yaml 2> $TestDrive / error.log | ConvertFrom-Json
277
+ It ' secure types can be passed as objects to resources but redacted in output: <operation> <property>' - TestCases @ (
278
+ @ { operation = ' get' ; property = ' actualState' }
279
+ @ { operation = ' set' ; property = ' beforeState' }
280
+ @ { operation = ' set' ; property = ' afterState' }
281
+ @ { operation = ' test' ; property = ' desiredState' }
282
+ @ { operation = ' test' ; property = ' actualState' }
283
+ @ { operation = ' export' ; property = $null }
284
+ ) {
285
+ param ($operation , $property )
286
+
287
+ $out = dsc - l trace config -f $PSScriptRoot / ../ examples/ secure_parameters.parameters.yaml $operation -f $PSScriptRoot / ../ examples/ secure_parameters.dsc.yaml 2> $TestDrive / error.log | ConvertFrom-Json
279
288
$LASTEXITCODE | Should - Be 0
280
- $out.results.Count | Should - Be 4
281
- $out.results [0 ].result.actualState.output | Should - BeExactly ' <secureValue>'
282
- $out.results [1 ].result.actualState.output | Should - BeExactly ' <secureValue>'
283
- $out.results [2 ].result.actualState.output[0 ] | Should - BeExactly ' <secureValue>'
284
- $out.results [2 ].result.actualState.output[1 ] | Should - BeExactly ' <secureValue>'
285
- $out.results [3 ].result.actualState.output | Should - BeExactly ' <secureValue>'
289
+ if ($operation -eq ' export' ) {
290
+ $out.resources.Count | Should - Be 4
291
+ $out.resources [0 ].properties.output | Should - BeExactly ' <secureValue>'
292
+ $out.resources [1 ].properties.output | Should - BeExactly ' <secureValue>'
293
+ $out.resources [2 ].properties.output[0 ] | Should - BeExactly ' <secureValue>'
294
+ $out.resources [2 ].properties.output[1 ] | Should - BeExactly ' <secureValue>'
295
+ $out.resources [3 ].properties.output | Should - BeExactly ' <secureValue>'
296
+ } else {
297
+ $out.results.Count | Should - Be 4 - Because ($out | ConvertTo-Json - Dep 10 | Out-String )
298
+ $out.results [0 ].result.$property.output | Should - BeExactly ' <secureValue>' - Because ($out | ConvertTo-Json - Dep 10 | Out-String )
299
+ $out.results [1 ].result.$property.output | Should - BeExactly ' <secureValue>'
300
+ $out.results [2 ].result.$property.output [0 ] | Should - BeExactly ' <secureValue>'
301
+ $out.results [2 ].result.$property.output [1 ] | Should - BeExactly ' <secureValue>'
302
+ $out.results [3 ].result.$property.output | Should - BeExactly ' <secureValue>'
303
+ }
286
304
}
287
305
288
- It ' secure types can be passed as objects to resources' {
289
- $out = dsc config -f $PSScriptRoot / ../ examples/ secure_parameters_shown.parameters.yaml get -f $PSScriptRoot / ../ examples/ secure_parameters.dsc.yaml | ConvertFrom-Json
306
+ It ' secure types can be passed as objects to resources: <operation> <property>' - TestCases @ (
307
+ # `set` beforeState is redacted in output, `test` desiredState is redacted in output so those test cases are not included here
308
+ @ { operation = ' get' ; property = ' actualState' }
309
+ @ { operation = ' set' ; property = ' afterState' }
310
+ @ { operation = ' test' ; property = ' actualState' }
311
+ @ { operation = ' export' ; property = $null }
312
+ ) {
313
+ param ($operation , $property )
314
+
315
+ $out = dsc config -f $PSScriptRoot / ../ examples/ secure_parameters_shown.parameters.yaml $operation -f $PSScriptRoot / ../ examples/ secure_parameters.dsc.yaml | ConvertFrom-Json
290
316
$LASTEXITCODE | Should - Be 0
291
- $out.results.Count | Should - Be 4
292
- $out.results [0 ].result.actualState.output.secureString | Should - BeExactly ' mySecret'
293
- $out.results [1 ].result.actualState.output.secureString | Should - BeExactly ' mySecretProperty'
294
- $out.results [2 ].result.actualState.output[0 ].secureString | Should - BeExactly ' item1'
295
- $out.results [2 ].result.actualState.output[1 ].secureString | Should - BeExactly ' item2'
296
- $out.results [3 ].result.actualState.output.secureObject.secureString | Should - BeExactly ' item2'
317
+ if ($operation -eq ' export' ) {
318
+ $out.resources.Count | Should - Be 4 - Because ($out | ConvertTo-Json - Dep 10 | Out-String )
319
+ $out.resources [0 ].properties.output.secureString | Should - BeExactly ' mySecret'
320
+ $out.resources [1 ].properties.output.secureString | Should - BeExactly ' mySecretProperty'
321
+ $out.resources [2 ].properties.output[0 ].secureString | Should - BeExactly ' item1'
322
+ $out.resources [2 ].properties.output[1 ].secureString | Should - BeExactly ' item2'
323
+ $out.resources [3 ].properties.output.secureObject.secureString | Should - BeExactly ' item2'
324
+ } else {
325
+ $out.results.Count | Should - Be 4
326
+ $out.results [0 ].result.$property.output.secureString | Should - BeExactly ' mySecret' - Because ($out | ConvertTo-Json - Dep 10 | Out-String )
327
+ $out.results [1 ].result.$property.output.secureString | Should - BeExactly ' mySecretProperty'
328
+ $out.results [2 ].result.$property.output [0 ].secureString | Should - BeExactly ' item1'
329
+ $out.results [2 ].result.$property.output [1 ].secureString | Should - BeExactly ' item2'
330
+ $out.results [3 ].result.$property.output.secureObject.secureString | Should - BeExactly ' item2'
331
+ }
297
332
}
298
333
299
334
It ' parameter types are validated for <type>' - TestCases @ (
0 commit comments