Skip to content

Commit fdf592b

Browse files
authored
Merge pull request #744 from psah434/pallavisah/passwordbox
Pallavisah/passwordbox
2 parents 6b75cb7 + 695bfa5 commit fdf592b

File tree

5 files changed

+181
-4
lines changed

5 files changed

+181
-4
lines changed

arm-ttk/testcases/CreateUIDefinition/Password-Textboxes-Must-Be-Used-For-Password-Parameters.test.ps1

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,17 @@ $passwordBoxes = $CreateUIDefinitionObject |
2525
foreach ($pwb in $passwordBoxes) { # Loop over each password box
2626
$controlName = $pwb.Name # and find the output it maps to.
2727
$theOutput = foreach ($out in $CreateUIDefinitionObject.parameters.outputs.psobject.properties) {
28-
if (($out.Value -like "*steps(*$controlName*") -or ($out.Value -like "*basics(*$controlName*")) {
29-
$out; break
28+
$outputValueType = $out.Value.GetType().Name
29+
if ($outputValueType -eq "PSCustomObject") {
30+
$outputJson = $out.Value | ConvertTo-Json -Compress
31+
if (($outputJson -like "*steps(*$controlName*") -or ($outputJson -like "*basics(*$controlName*")) {
32+
$out; break
33+
}
34+
}
35+
else {
36+
if (($out.Value -like "*steps(*$controlName*") -or ($out.Value -like "*basics(*$controlName*")) {
37+
$out; break
38+
}
3039
}
3140
}
3241

@@ -39,13 +48,13 @@ foreach ($pwb in $passwordBoxes) { # Loop over each password box
3948

4049
# If we couldn't find it, write an error.
4150
if (-not $MainTemplateParam) {
42-
Write-Error "Password box $($pwb.Name) is missing from main template parameters "-TargetObject $pwb
51+
Write-Error "Password box $($pwb.Name) linked to output $($theOutput.Name) is missing from main template parameters "-TargetObject $pwb
4352
continue
4453
}
4554

4655
# If the main template parameter type is neither a Secure String nor a Secure Object
4756
if (($MainTemplateParam.type -ne 'SecureString') -and ($MainTemplateParam.type -ne 'SecureObject')) {
4857
# write an error.
49-
Write-Error "PasswordBox controls must use secureString or secureObject parameter types. The Main template parameter '$($pwb.Name)' is a '$($MainTemplateParam.type)'" -TargetObject @($pwb, $MainTemplateParam)
58+
Write-Error "PasswordBox controls must use secureString or secureObject parameter types. The Main template parameter '$($theOutput.Name)' linked to '$($pwb.Name)' is a '$($MainTemplateParam.type)'" -TargetObject @($pwb, $MainTemplateParam)
5059
}
5160
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {
5+
"location": {
6+
"type": "string",
7+
"defaultValue": "[resourceGroup().location]",
8+
"metadata": {
9+
"description": "Location."
10+
}
11+
},
12+
"certificates": {
13+
"type": "object",
14+
"defaultValue": [
15+
{
16+
"password": "password"
17+
}
18+
],
19+
"metadata": {
20+
"description": "Backend data."
21+
}
22+
}
23+
},
24+
"variables": {
25+
},
26+
"resources": [
27+
],
28+
"outputs": {
29+
"location": {
30+
"type": "string",
31+
"value": "[parameters('location')]"
32+
}
33+
}
34+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
3+
"handler": "Microsoft.Azure.CreateUIDef",
4+
"version": "0.1.2-preview",
5+
"parameters": {
6+
"basics": [
7+
{
8+
"name": "settings",
9+
"label": "Settings",
10+
"bladeTitle": "Settings",
11+
"elements": [
12+
{
13+
"type": "Microsoft.Common.Section",
14+
"name": "section",
15+
"label": "Section Settings",
16+
"visible": "true",
17+
"elements": [
18+
{
19+
"type": "Microsoft.Common.PasswordBox",
20+
"name": "passwordBox",
21+
"label": {
22+
"password": "Password",
23+
"confirmPassword": "Confirm password"
24+
},
25+
"toolTip": "Password for password box",
26+
"visible": true,
27+
"constraints": {
28+
"required": true,
29+
"regex": "^[\\S]{10,25}$",
30+
"validationMessage": "Password must be between 10 and 25 characters."
31+
},
32+
"options": {
33+
"hideConfirmation": false
34+
}
35+
}
36+
]
37+
}
38+
]
39+
}
40+
],
41+
"outputs": {
42+
"Location": "[location()]",
43+
"certificates": {
44+
"0": {
45+
"password": "[coalesce(steps('settings').section.passwordBox, 'NA')]"
46+
}
47+
}
48+
}
49+
}
50+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {
5+
"location": {
6+
"type": "string",
7+
"defaultValue": "[resourceGroup().location]",
8+
"metadata": {
9+
"description": "Location."
10+
}
11+
},
12+
"certificates": {
13+
"type": "secureObject",
14+
"defaultValue": [
15+
{
16+
"password": "password"
17+
}
18+
],
19+
"metadata": {
20+
"description": "Backend data."
21+
}
22+
}
23+
},
24+
"variables": {
25+
},
26+
"resources": [
27+
],
28+
"outputs": {
29+
"location": {
30+
"type": "string",
31+
"value": "[parameters('location')]"
32+
}
33+
}
34+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
3+
"handler": "Microsoft.Azure.CreateUIDef",
4+
"version": "0.1.2-preview",
5+
"parameters": {
6+
"basics": [
7+
{
8+
"name": "settings",
9+
"label": "Settings",
10+
"bladeTitle": "Settings",
11+
"elements": [
12+
{
13+
"type": "Microsoft.Common.Section",
14+
"name": "section",
15+
"label": "Section Settings",
16+
"visible": "true",
17+
"elements": [
18+
{
19+
"type": "Microsoft.Common.PasswordBox",
20+
"name": "passwordBox",
21+
"label": {
22+
"password": "Password",
23+
"confirmPassword": "Confirm password"
24+
},
25+
"toolTip": "Password for password box",
26+
"visible": true,
27+
"constraints": {
28+
"required": true,
29+
"regex": "^[\\S]{10,25}$",
30+
"validationMessage": "Password must be between 10 and 25 characters."
31+
},
32+
"options": {
33+
"hideConfirmation": false
34+
}
35+
}
36+
]
37+
}
38+
]
39+
}
40+
],
41+
"outputs": {
42+
"Location": "[location()]",
43+
"certificates": {
44+
"0": {
45+
"password": "[coalesce(steps('settings').section.passwordBox, 'NA')]"
46+
}
47+
}
48+
}
49+
}
50+
}

0 commit comments

Comments
 (0)