mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 04:36:39 +00:00
Create new test for Get-Credential which requires module to create a test host
This commit is contained in:
1 parent
d7b31245d3
commit
5644c4c54b
2 files changed
+303
No files matched your search
+31
@@ -0,0 +1,31 @@
|
||||
if ( ! (get-module -ea silentlycontinue TestHostCS ))
|
||||
{
|
||||
$root = git rev-parse --show-toplevel
|
||||
$pestertestroot = join-path $root test/powershell
|
||||
$common = join-path $pestertestroot Common
|
||||
$hostmodule = join-path $common TestHostCS.psm1
|
||||
import-module $hostmodule
|
||||
}
|
||||
Describe "Get-Credential Test" -tag "CI" {
|
||||
BeforeAll {
|
||||
$th = New-TestHost
|
||||
$th.UI.StringForSecureString = "This is a test"
|
||||
$rs = [runspacefactory]::Createrunspace($th)
|
||||
$rs.open()
|
||||
$ps = [powershell]::Create()
|
||||
$ps.Runspace = $rs
|
||||
$ps.Commands.Clear()
|
||||
}
|
||||
AfterAll {
|
||||
$rs.Close()
|
||||
$rs.Dispose()
|
||||
$ps.Dispose()
|
||||
}
|
||||
It "Get-Credential produces as credential object" {
|
||||
$cred = $ps.AddScript("Get-Credential -User Joe -Message Foo").Invoke() | Select-Object -First 1
|
||||
$cred.gettype().FullName | Should Be "System.Management.Automation.PSCredential"
|
||||
$netcred = $cred.GetNetworkCredential()
|
||||
$netcred.UserName | Should be "Joe"
|
||||
$netcred.Password | Should be "this is a test"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user