mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Remove input text from the error message resulted by SecureString and PSCredential conversion failure (#19977)
This commit is contained in:
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user