forked from PowerShell/PSScriptAnalyzer
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAvoidConvertToSecureStringWithPlainText.tests.ps1
More file actions
24 lines (21 loc) · 1.13 KB
/
AvoidConvertToSecureStringWithPlainText.tests.ps1
File metadata and controls
24 lines (21 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Set-Alias ctss ConvertTo-SecureString
$violationMessage = "File 'AvoidConvertToSecureStringWithPlainText.ps1' uses ConvertTo-SecureString with plaintext. This will expose secure information. Encrypted standard strings should be used instead."
$violationName = "PSAvoidUsingConvertToSecureStringWithPlainText"
$directory = Split-Path -Parent $MyInvocation.MyCommand.Path
$violations = Invoke-ScriptAnalyzer $directory\AvoidConvertToSecureStringWithPlainText.ps1 | Where-Object {$_.RuleName -eq $violationName}
$noViolations = Invoke-ScriptAnalyzer $directory\AvoidConvertToSecureStringWithPlainTextNoViolations.ps1 | Where-Object {$_.RuleName -eq $violationName}
Describe "AvoidConvertToSecureStringWithPlainText" {
Context "When there are violations" {
It "has 3 ConvertTo-SecureString violations" {
$violations.Count | Should -Be 3
}
It "has the correct description message" {
$violations[0].Message | Should -Match $violationMessage
}
}
Context "When there are no violations" {
It "returns no violations" {
$noViolations.Count | Should -Be 0
}
}
}