Remove input text from the error message resulted by SecureString and PSCredential conversion failure (#19977)

This commit is contained in:
Armaan Mcleod
2023-07-17 10:30:10 -07:00
committed by GitHub
parent 3ce65f39e0
commit d24285f437
4 changed files with 39 additions and 2 deletions
@@ -41,4 +41,14 @@ Describe "SecureString conversion tests" -Tags "CI" {
$ss2 = $encodedStr | ConvertTo-SecureString -Key $key
$ss2 | ConvertFrom-SecureString -AsPlainText | Should -BeExactly $testString
}
It "Using invalid secure string with ConvertFrom-SecureString produces an exception message without value" {
$ex = { ConvertFrom-SecureString "1234" } | Should -Throw -ErrorId "CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.ConvertFromSecureStringCommand" -PassThru
$ex.Exception.Message | Should -Not -Match "1234"
}
It "Using invalid securestring with cast produces an exception message without value" {
$ex = { [securestring]"1234" } | Should -Throw -ErrorId "ConvertToFinalInvalidCastException" -PassThru
$ex.Exception.Message | Should -Not -Match "1234"
}
}