Skip to content

Commit 0a33644

Browse files
author
Kapil Borle
committed
Add test case for rule supression
1 parent 68c3c35 commit 0a33644

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Tests/Engine/RuleSuppression.tests.ps1

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ Function do-something
2121
}
2222
'@
2323

24+
$ruleSuppressionInConfiguration = @'
25+
Configuration xFileUpload
26+
{
27+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "")]
28+
param ([string] $decryptedPassword)
29+
$securePassword = ConvertTo-SecureString $decryptedPassword -AsPlainText -Force
30+
}
31+
'@
32+
2433
Describe "RuleSuppressionWithoutScope" {
2534
Context "Function" {
2635
It "Does not raise violations" {
@@ -49,6 +58,13 @@ Describe "RuleSuppressionWithoutScope" {
4958
}
5059
}
5160

61+
Context "Rule suppression within DSC Configuration definition" {
62+
It "Suppresses rule" {
63+
$suppressedRule = Invoke-ScriptAnalyzer -ScriptDefinition $ruleSuppressionInConfiguration -SuppressedOnly
64+
$suppressedRule.Count | Should Be 1
65+
}
66+
}
67+
5268
if (!$testingLibraryUsage)
5369
{
5470
Context "Bad Rule Suppression" {

0 commit comments

Comments
 (0)