mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Add password confirmation in Get-Credential (#12782)
* Add parameter -ReEnterPassword to prompt user to re-enter the password for confirmation * Add new public overload function PromptForCredential
This commit is contained in:
@@ -102,4 +102,21 @@ Describe "Get-Credential Test" -Tag "CI" {
|
||||
$netcred.UserName | Should -Be "John"
|
||||
$netcred.Password | Should -Be "CredTest"
|
||||
}
|
||||
It "Get-credential Joe -ConfirmPassword set to false"{
|
||||
$cred = $ps.AddScript("Get-Credential Joe -ConfirmPassword:`$false").Invoke() | Select-Object -First 1
|
||||
$cred | Should -BeOfType System.Management.Automation.PSCredential
|
||||
$netcred = $cred.GetNetworkCredential()
|
||||
$netcred.UserName | Should -Be "Joe"
|
||||
$netcred.Password | Should -Be "This is a test"
|
||||
$th.ui.Streams.Prompt[-1] | Should -Match "Credential:[^:]+:[^:]+"
|
||||
}
|
||||
It "Get-Credential with only -ConfirmPassword" {
|
||||
$cred = $ps.AddScript("Get-Credential -ConfirmPassword").Invoke() | Select-Object -First 1
|
||||
$cred | Should -BeOfType System.Management.Automation.PSCredential
|
||||
$netcred = $cred.GetNetworkCredential()
|
||||
$netcred.UserName | Should -Be "John"
|
||||
$netcred.Password | Should -Be "This is a test"
|
||||
$th.ui.Streams.Prompt[-2] | Should -Match "Credential:[^:]+:[^:]+"
|
||||
$th.ui.Streams.Prompt[-1] | Should -Match "Credential@[^@]+@[^@]+"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user