Skip to content

Commit b2c9b1c

Browse files
author
Pallavi Sah
committed
Merge branch 'master' into CacheUpdate-2023-01-21
2 parents a08c8ac + 40ed1a0 commit b2c9b1c

File tree

13 files changed

+533
-263
lines changed

13 files changed

+533
-263
lines changed

arm-ttk/cache/AllAzureResources.cache.json

Lines changed: 227 additions & 214 deletions
Large diffs are not rendered by default.

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
}

arm-ttk/testcases/CreateUIDefinition/PasswordBoxes-Must-Have-Min-Length.test.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ foreach ($pwb in $passwordBoxes) { # Loop over each password box
4747
$totalMins += $match.Groups['Min'].Value -as [int]
4848
}
4949
if ($passWordMinLength -gt $totalMins) {
50-
Write-Warning "PasswordBox '$($pwb.Name)' regex does not have a minimum length of $PasswordMinLength" -TargetObject $pwb
50+
Write-Warning "PasswordBox '$($pwb.Name)' regex does not have a minimum length of $PasswordMinLength"
5151
}
5252
}
5353
} catch {

arm-ttk/testcases/CreateUIDefinition/Textboxes-Are-Well-Formed.test.ps1

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,9 @@ param(
1212
)
1313

1414
# First, find all textboxes within CreateUIDefinition.
15-
1615
$allTextBoxes = $CreateUiDefinitionObject | Find-JsonContent -Key type -value Microsoft.Common.TextBox
17-
# Match length constraint at beginning of regex.
18-
# Input string starts with ^(?=.{N,N} ^ ( ? = . {N ,N}
19-
$lengthConstraintRegexAtBeginning = [Regex]::new('^[\^][\(][\?][=][\.]\{(?<Min>\d+),(?<Max>\d+)?\}.*')
20-
$lengthConstraintRegexAtEnd = [Regex]::new('\{(?<Min>\d+),(?<Max>\d+)?\}(\$)?$')
16+
# Regex Constraint should contain one of following pattern (Length Check): {m,n} or {m,} or {m}
17+
$lengthContraintRegex = [Regex]::new('\{(?<Min>\d+)(?:,(?<Max>\d+)|,)?\}')
2118

2219
foreach ($textbox in $allTextBoxes) {
2320
# Then we walk over each textbox.
@@ -26,6 +23,7 @@ foreach ($textbox in $allTextBoxes) {
2623
Write-Error -Message "Textbox $($textbox.Name) is missing constraints" -ErrorId Textboxes.Are.Well.Formed.Missing.Constraints -TargetObject $textbox # error
2724
continue # and continue (since additional failures would be noise).
2825
}
26+
2927
$constraintRegexString = "";
3028
if ($textbox.constraints.validations) {
3129
$constraintRegexString = foreach ($validation in $textbox.constraints.validations) {
@@ -37,27 +35,27 @@ foreach ($textbox in $allTextBoxes) {
3735
elseif ($textbox.constraints.regex) {
3836
$constraintRegexString = $textbox.constraints.regex
3937
if (-not $textbox.constraints.validationMessage) {
40-
# If there's not a validation message
38+
# Regex constraint is missing validation message
4139
Write-Error -Message "Textbox $($textbox.Name) is missing constraints.validationMessage" -ErrorId Textboxes.Are.Well.Formed.Missing.Constraints.ValidationMessage -TargetObject $textbox #error.
4240
}
4341
}
42+
4443
if (-not $constraintRegexString ) {
45-
# If the constraint didn't have a regex,
44+
# If the constraint didn't have a regex
4645
Write-Error -Message "Textbox $($textbox.Name) is missing constraints.regex or regex property in constraints.validations" -ErrorId Textboxes.Are.Well.Formed.Missing.Constraints.Regex -TargetObject $textbox #error.
4746
}
4847
else {
4948
try {
50-
# If it did,
49+
# If it did
5150
$constraintWasRegex = [Regex]::new($constraintRegexString) # try to cast to a regex
52-
$hasLengthConstraintAtBeginning = $lengthConstraintRegexAtBeginning.Match($constraintRegexString)
53-
$hasLengthConstraintAtEnd = $lengthConstraintRegexAtEnd.Match($constraintRegexString)
51+
$hasLengthConstraint = $lengthContraintRegex.Match($constraintRegexString)
5452

55-
if (-not ($hasLengthConstraintAtBeginning.Success -or $hasLengthConstraintAtEnd.Success -or $isExpression.Success)) {
53+
if (-not ($hasLengthConstraint.Success)) {
5654
Write-Warning "TextBox '$($textBox.Name)' regex does not have a length constraint."
5755
}
5856
}
5957
catch {
60-
$err = $_ # if that fails,
58+
$err = $_ # if that fails
6159
Write-Error -Message "Textbox $($textbox.Name) regex is invalid: $($err)" -ErrorId Textboxes.Are.Well.Formed.Invalid.Constraints.Regex.Expressison -TargetObject $textbox #error.
6260
}
6361
}

arm-ttk/testcases/CreateUIDefinition/Tooltips-Should-Be-Present.test.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ $shouldHaveTooltips = $CreateUIDefinitionObject |
2121
$noToolTipControls = "Microsoft.Common.InfoBox",
2222
"Microsoft.Common.Section",
2323
"Microsoft.Common.TextBlock",
24-
"Microsoft.Solutions.ArmApiControl"
24+
"Microsoft.Solutions.ArmApiControl",
25+
"Microsoft.Common.EditableGrid"
2526

2627
foreach ($shouldHave in $shouldHaveTooltips) {
2728
# then loop through each control
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+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
3+
"handler": "Microsoft.Compute.MultiVm",
4+
"version": "0.1.2-preview",
5+
"parameters": {
6+
"basics": [
7+
{
8+
"name": "dbAdminPassword",
9+
"type": "Microsoft.Common.PasswordBox",
10+
"label": {
11+
"password": "Password",
12+
"confirmPassword": "Confirm password"
13+
},
14+
"toolTip": "Admin password for the database",
15+
"constraints": {
16+
"required": true,
17+
"regex": "^(?=.*[A-Z])(?=.*[a-z])(?=.*\\d)[A-Za-z\\d\\$\\&\\+\\,:\\=\\?@#|'.\\^\\*!\\-_~/'\\[\\]\\{\\}\"]{8,}$",
18+
"validationMessage": "The password must contain at least 8 characters, with at least 1 uppercase letter, 1 lowercase letter and 1 number, and special characters, but should not contain > < ( ) % ; \\."
19+
},
20+
"options": {
21+
"hideConfirmation": false
22+
},
23+
"visible": true
24+
}
25+
],
26+
"steps": []
27+
}
28+
}

0 commit comments

Comments
 (0)