From ab224411f8bc4e7683a3c274d474a300242f3290 Mon Sep 17 00:00:00 2001 From: "Stephen Weatherford (MSFT)" Date: Mon, 22 Feb 2021 16:10:37 -0800 Subject: [PATCH] 21122.7 validation assembly (#1199) * 21122.7 validation assembly * Add test * Add 1185 test Co-authored-by: Stephen Weatherford --- package.json | 2 +- test/LinkedTemplates.test.ts | 85 +++++++++---------- test/functional/linkedTemplates.test.ts | 27 ++++++ .../subfolder/child14.json | 5 ++ .../tc14-contentVersion/tc14.json | 53 ++++++++++++ .../tc14-contentVersion/tc14.parameters.json | 6 ++ 6 files changed, 133 insertions(+), 45 deletions(-) create mode 100644 test/templates/linkedTemplates/tc14-contentVersion/subfolder/child14.json create mode 100644 test/templates/linkedTemplates/tc14-contentVersion/tc14.json create mode 100644 test/templates/linkedTemplates/tc14-contentVersion/tc14.parameters.json diff --git a/package.json b/package.json index 5c85c2d87..b9fdfcaad 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "version": "0.15.0-alpha1", "publisher": "msazurermtools", "config": { - "ARM_LANGUAGE_SERVER_NUGET_VERSION": "3.0.0-preview.21113.1" + "ARM_LANGUAGE_SERVER_NUGET_VERSION": "3.0.0-preview.21122.7" }, "categories": [ "Azure", diff --git a/test/LinkedTemplates.test.ts b/test/LinkedTemplates.test.ts index 2caea4de6..554eb6d9d 100644 --- a/test/LinkedTemplates.test.ts +++ b/test/LinkedTemplates.test.ts @@ -75,58 +75,55 @@ suite("Linked templates regressions", () => { // TODO: For some reason, these two tests are failing consistently in the // Windows build pipeline, but not locally or on other platforms. if (!isWin32) { - - // tslint:disable-next-line: no-suspicious-comment - /* TODO: Regressed by https://github.com/microsoft/vscode-azurearmtools/issues/1185 - testWithLanguageServer("Nested template wrong param type", async () => { - await testDiagnostics( - { - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "resources": [ - { - "type": "Microsoft.Resources/deployments", - "apiVersion": "2019-10-01", - "name": "inner", - "properties": { - "expressionEvaluationOptions": { - "scope": "inner" - }, - "mode": "Incremental", + testWithLanguageServer("Nested template wrong param type", async () => { + await testDiagnostics( + { + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "resources": [ + { + "type": "Microsoft.Resources/deployments", + "apiVersion": "2019-10-01", + "name": "inner", + "properties": { + "expressionEvaluationOptions": { + "scope": "inner" + }, + "mode": "Incremental", + "parameters": { + "parameter1": { + "value": 123 + } + }, + "template": { + "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", "parameters": { "parameter1": { - "value": 123 + "type": "string" } }, - "template": { - "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "parameter1": { - "type": "string" - } - }, - "resources": [] - } + "resources": [] } } - ] - }, - { - includeRange: true, - parameters: { - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", - "contentVersion": "1.0.0.0", - "parameters": { - } } - }, - [ - "Error: Template validation failed: Template parameter JToken type is not valid. Expected 'String, Uri'. Actual 'Integer'. Please see https://aka.ms/arm-deploy/#parameter-file for usage details. (arm-template (validation)) [9,21-9,21] [The error occurred in a nested template near here] [13,19-13,19]", - "Warning: The parameter 'parameter1' is never used. (arm-template (expressions)) [23,13-23,25]" ] - ); - });*/ + }, + { + includeRange: true, + parameters: { + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", + "contentVersion": "1.0.0.0", + "parameters": { + } + } + }, + [ + "Error: Template validation failed: Template parameter JToken type is not valid. Expected 'String, Uri'. Actual 'Integer'. Please see https://aka.ms/arm-deploy/#parameter-file for usage details. (arm-template (validation)) [9,21-9,21] [The error occurred in a nested template near here] [23,21-23,21]", + "Warning: The parameter 'parameter1' is never used. (arm-template (expressions)) [23,13-23,25]" + ] + ); + }); testWithLanguageServer("Nested template missing properties", async () => { await testDiagnostics( diff --git a/test/functional/linkedTemplates.test.ts b/test/functional/linkedTemplates.test.ts index a40f07b95..c2045332b 100644 --- a/test/functional/linkedTemplates.test.ts +++ b/test/functional/linkedTemplates.test.ts @@ -533,4 +533,31 @@ suite("Linked templates functional tests", () => { } ); } + + // tslint:disable-next-line: no-suspicious-comment + // TODO: Hangs on build machine? + if (!isWin32) { + createLinkedTemplateTest( + "tc14", + "Incorrect content version specified", + { + mainTemplateFile: "templates/linkedTemplates/tc14-contentVersion/.json", + mainParametersFile: ".parameters.json", + mainTemplateExpected: [ + // tslint:disable-next-line: no-suspicious-comment + // TODO: See 1144 - line/col in the additional info location is incorrect + "Error: Template validation failed: The content version contained in the template '1.2.3.4' does not match the content version found in the deployment object's TemplateLink property '1.2.3.5'. Please see https://aka.ms/arm-deploy for usage details. (arm-template (validation)) [40,27] [The error occurred in a linked template near here] [40,27]", + ], + waitForDiagnosticSubstring: "The content version", // needed? + linkedTemplates: [ + { + parentTemplateFile: "templates/linkedTemplates/tc14-contentVersion/.json", + linkedTemplateFile: "templates/linkedTemplates/tc14-contentVersion/subfolder/child14.json", + expected: [ + ] + } + ] + } + ); + } }); diff --git a/test/templates/linkedTemplates/tc14-contentVersion/subfolder/child14.json b/test/templates/linkedTemplates/tc14-contentVersion/subfolder/child14.json new file mode 100644 index 000000000..86845f778 --- /dev/null +++ b/test/templates/linkedTemplates/tc14-contentVersion/subfolder/child14.json @@ -0,0 +1,5 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.2.3.4", + "resources": [] +} diff --git a/test/templates/linkedTemplates/tc14-contentVersion/tc14.json b/test/templates/linkedTemplates/tc14-contentVersion/tc14.json new file mode 100644 index 000000000..e705e5985 --- /dev/null +++ b/test/templates/linkedTemplates/tc14-contentVersion/tc14.json @@ -0,0 +1,53 @@ +{ + // Verify correct scope of expressions, variables, parameters + + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "resources": [ + { + "name": "linkedDeployment1", + "type": "Microsoft.Resources/deployments", + "apiVersion": "2020-10-01", + "properties": { + "mode": "Incremental", + "templateLink": { + "relativePath": "subfolder/child14.json", + // correct content version - OK + "contentVersion": "1.2.3.4" + }, + "parameters": { + } + } + }, + { + "name": "linkedDeployment1", + "type": "Microsoft.Resources/deployments", + "apiVersion": "2020-10-01", + "properties": { + "mode": "Incremental", + "templateLink": { + "relativePath": "subfolder/child14.json" + // no content version - OK + }, + "parameters": { + } + } + }, + { + "name": "linkedDeployment1", + "type": "Microsoft.Resources/deployments", + "apiVersion": "2020-10-01", + "properties": { + "mode": "Incremental", + "templateLink": { + "relativePath": "subfolder/child14.json", + // incorrect content version - ERROR + "contentVersion": "1.2.3.5" + }, + "parameters": { + } + } + } + ], + "outputs": {} +} diff --git a/test/templates/linkedTemplates/tc14-contentVersion/tc14.parameters.json b/test/templates/linkedTemplates/tc14-contentVersion/tc14.parameters.json new file mode 100644 index 000000000..fb2d7f1a9 --- /dev/null +++ b/test/templates/linkedTemplates/tc14-contentVersion/tc14.parameters.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", + "contentVersion": "1.0.0.0", + "parameters": { + } +} \ No newline at end of file