@@ -76,6 +76,28 @@ Describe 'Azure.Deployment' -Tag 'Deployment' {
76
76
$targetNames | Should - BeIn ' secret_good' , ' streaming_jobs_good' , ' reference_good' ;
77
77
}
78
78
}
79
+
80
+ Context ' With Template' {
81
+ BeforeAll {
82
+ $templatePath = Join-Path - Path $here - ChildPath ' deployment.tests.json' ;
83
+ $outputFile = Join-Path - Path $rootPath - ChildPath out/ tests/ Resources.Deployment.json;
84
+ Export-AzRuleTemplateData - TemplateFile $templatePath - OutputPath $outputFile ;
85
+ $result = Invoke-PSRule - Module PSRule.Rules.Azure - InputPath $outputFile - Outcome All - WarningAction Ignore - ErrorAction Stop;
86
+ }
87
+
88
+ It ' Azure.Deployment.Name' {
89
+ $filteredResult = $result | Where-Object { $_.RuleName -eq ' Azure.Deployment.Name' };
90
+
91
+ # Fail
92
+ $ruleResult = @ ($filteredResult | Where-Object { $_.Outcome -eq ' Fail' });
93
+ $ruleResult | Should - BeNullOrEmpty;
94
+
95
+ # Pass
96
+ $ruleResult = @ ($filteredResult | Where-Object { $_.Outcome -eq ' Pass' });
97
+ $ruleResult | Should -Not - BeNullOrEmpty;
98
+ $ruleResult.Length | Should - Be 2 ;
99
+ }
100
+ }
79
101
}
80
102
81
103
Describe ' Azure.Deployment' - Tag ' Deployment' {
@@ -162,9 +184,18 @@ Describe 'Azure.Deployment.AdminUsername' -Tag 'Deployment' {
162
184
$ruleResult | Should -Not - BeNullOrEmpty;
163
185
$ruleResult.Length | Should - Be 3 ;
164
186
}
187
+ }
165
188
166
- It ' Azure.Deployment.Name' {
167
- $filteredResult = $result | Where-Object { $_.RuleName -eq ' Azure.Deployment.Name' };
189
+ Context ' With Bicep with symbolic names' {
190
+ BeforeAll {
191
+ $templatePath = Join-Path - Path $here - ChildPath ' Bicep/SymbolicNameTestCases/Tests.Bicep.5.json' ;
192
+ $outputFile = Join-Path - Path $rootPath - ChildPath out/ tests/ Resources.Deployment.json;
193
+ Export-AzRuleTemplateData - TemplateFile $templatePath - OutputPath $outputFile ;
194
+ $result = Invoke-PSRule - Module PSRule.Rules.Azure - InputPath $outputFile - Outcome All - WarningAction Ignore - ErrorAction Stop;
195
+ }
196
+
197
+ It ' Azure.Deployment.AdminUsername' {
198
+ $filteredResult = $result | Where-Object { $_.RuleName -eq ' Azure.Deployment.AdminUsername' };
168
199
169
200
# Fail
170
201
$ruleResult = @ ($filteredResult | Where-Object { $_.Outcome -eq ' Fail' });
@@ -173,7 +204,7 @@ Describe 'Azure.Deployment.AdminUsername' -Tag 'Deployment' {
173
204
# Pass
174
205
$ruleResult = @ ($filteredResult | Where-Object { $_.Outcome -eq ' Pass' });
175
206
$ruleResult | Should -Not - BeNullOrEmpty;
176
- $ruleResult.Length | Should - Be 2 ;
207
+ $ruleResult.Length | Should - Be 10 ;
177
208
}
178
209
}
179
210
}
0 commit comments