Open v-mosh21 opened 2 years ago
I remove this particular test/error in the 0.8 release.
I'm going to leave this active as a task to fix the test properly.
TLDR; there are a few controls that allow specific setting of the value property - in that property the proper functions may be used and we don't detect them. As well, those controls have multiple values so in theory we need to check all of the values for each element of the array to ensure they match.
TODO is in the code with more detail.
Also, this should be caught in pre-flight - so may cross the bar for TTK.
Issue: Got "output cosmosFreeApply does not return the expected type 'bool'" error when using test toolkit to check the template: https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/test-toolkit#test-parameters.
Investigation:
3.When using the Test-AzTemplate to check template, I got below error: Validating customertest\createUiDefinition.json JSONFiles Should Be Valid [+] JSONFiles Should Be Valid (7 ms)
Allowed Values Should Actually Be Allowed [+] Allowed Values Should Actually Be Allowed (21 ms) Controls In Outputs Must Exist [+] Controls In Outputs Must Exist (4 ms) CreateUIDefinition Must Not Have Blanks [+] CreateUIDefinition Must Not Have Blanks (5 ms) CreateUIDefinition Should Have Schema [+] CreateUIDefinition Should Have Schema (5 ms) Credential Confirmation Should Not Be Hidden [+] Credential Confirmation Should Not Be Hidden (16 ms) Handler Must Be Correct [+] Handler Must Be Correct (4 ms) HideExisting Must Be Correctly Handled [+] HideExisting Must Be Correctly Handled (15 ms) Location Should Be In Outputs [+] Location Should Be In Outputs (3 ms) CreateUIDefinition [-] Outputs Must Be Present In Template Parameters (28 ms) output cosmosFreeApply does not return the expected type 'bool'
Parameters Without Default Must Exist In CreateUIDefinition [+] Parameters Without Default Must Exist In CreateUIDefinition (4 ms) Password Textboxes Must Be Used For Password Parameters [+] Password Textboxes Must Be Used For Password Parameters (8 ms) PasswordBoxes Must Have Min Length [+] PasswordBoxes Must Have Min Length (8 ms)
.......
Pass : 47 Fail : 1 Total : 48
4.Navigate to the source script which is used to check output parameters: https://github.com/Azure/arm-ttk/blob/master/arm-ttk/testcases/CreateUIDefinition/Outputs-Must-Be-Present-In-Template-Parameters.test.ps1
It is evaluating two values: outputParameterType and firstOutputFunction:
The $af.Key and $af.Value are retrieved from $AllowedFunctionInOutput as below:
Note the outputParameterType is generated from template parameter type (from mainTemplate) and firstOutputFunction is generated from the function name of the output (from CreateUiDefinition):
The outputParameterType is bool which is expected, however, the firstOutputFunction in this case gets a value as steps which is not in above $AllowedFunctionInOutput values {'equals', 'less', 'lessOrEquals', 'greater', 'greaterOrEquals', 'and', 'or','not', 'true', 'false', 'contains','empty','coalesce','if'}. Therefore, it results in an error.
It looks like logic is not suitable in CreateUiDefinition because this file is made up of different elements instead of normal function used in ARM template.
May I ask if you could help to look at and fix the issue?