From be4e8bfccadf6aeaf4a8d606e26b6e64f4becf05 Mon Sep 17 00:00:00 2001 From: Brian Moore Date: Fri, 21 Jan 2022 16:14:19 -0600 Subject: [PATCH] fix 569 (#573) --- ...RIs-Should-Be-Properly-Constructed.test.ps1 | 5 ++--- .../Pass/Concat-in-URL.json | 18 ++++++++++++------ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/arm-ttk/testcases/deploymentTemplate/URIs-Should-Be-Properly-Constructed.test.ps1 b/arm-ttk/testcases/deploymentTemplate/URIs-Should-Be-Properly-Constructed.test.ps1 index ee7ad880..14331d3a 100644 --- a/arm-ttk/testcases/deploymentTemplate/URIs-Should-Be-Properly-Constructed.test.ps1 +++ b/arm-ttk/testcases/deploymentTemplate/URIs-Should-Be-Properly-Constructed.test.ps1 @@ -22,15 +22,14 @@ foreach ($found in $foundObjects) { # Walk over each found object foreach ($prop in $found.psobject.properties) { # then walk thru each property if ($prop.Name -notmatch 'ur[il]$') { continue } # skipping ones that are not uri/url if (-not $prop.value | ?) { continue } # and ones that do not contain an expression. - - # If the value contained expressions, but not the function uri $foundBadFunction = $prop.Value | ? -FunctionName ($FunctionNotAllowedInUri -join '|') $foundUriFunction = $prop.Value | ? -FunctionName uri + if ( ($foundBadFunction -and -not $foundUriFunction) -or - $foundBadFunction.Index -lt $foundUriFunction.Index + ($foundBadFunction.Index -lt $foundUriFunction.Index -and $foundBadFunction) ) { Write-Error "Function'$($foundBadFunction.Groups['FunctionName'].Value)' found within '$($prop.Name)" -TargetObject $found -ErrorId "URI.Improperly.Constructed" } diff --git a/unit-tests/URIs-Should-Be-Properly-Constructed/Pass/Concat-in-URL.json b/unit-tests/URIs-Should-Be-Properly-Constructed/Pass/Concat-in-URL.json index 7dadd6d0..ee44bd70 100644 --- a/unit-tests/URIs-Should-Be-Properly-Constructed/Pass/Concat-in-URL.json +++ b/unit-tests/URIs-Should-Be-Properly-Constructed/Pass/Concat-in-URL.json @@ -1,9 +1,15 @@ { -"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "outputs": { - "ServerUrl": { - "type": "string", - "value": "[uri(concat('http://', reference(variables('publicIPAddressName')).dnsSettings.fqdn), 'somepath')]" - } + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "resources": [], + "outputs": { + "ServerUrl": { + "type": "string", + "value": "[uri(concat('http://', reference(variables('publicIPAddressName')).dnsSettings.fqdn), 'somepath')]" + }, + "otherUri": { + "type": "string", + "value": "[uri(reference(resourceId('Microsoft.KeyVault/vaults/keys', 'keyVaultName', 'keyName'), '2021-06-01-preview').keyUri, 'blah')]" } + } }