Increase code coverage #22
@ -73,10 +73,11 @@ Describe "New-CredentialStoreItem" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Context "Test optional parameter lookup" {
|
Context "Test optional parameter lookup" {
|
||||||
|
$UserName = 'myUser'
|
||||||
|
$Password = ConvertTo-SecureString -String "mypasswd" -AsPlainText -Force
|
||||||
Mock Get-Credential {
|
Mock Get-Credential {
|
||||||
return [PSCustomObject]@{
|
return [PSCredential]::new($UserName, $Password)
|
||||||
UserName = 'myUser'
|
|
||||||
Password = ConvertTo-SecureString -String "mypasswd" -AsPlainText -Force
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
It "Test missing Credential" {
|
It "Test missing Credential" {
|
||||||
@ -85,17 +86,16 @@ Describe "New-CredentialStoreItem" {
|
|||||||
$writtenItem = Get-CredentialStoreItem -Path $tmpCS -Shared -RemoteHost 'foobar3'
|
$writtenItem = Get-CredentialStoreItem -Path $tmpCS -Shared -RemoteHost 'foobar3'
|
||||||
$writtenItem.UserName | Should -Be "myUser"
|
$writtenItem.UserName | Should -Be "myUser"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Context "General Exception handling" {
|
Context "General Exception handling" {
|
||||||
Mock Test-CredentialStore {return $false}
|
Mock Test-CredentialStore {return $false}
|
||||||
|
$UserName = 'myUser'
|
||||||
|
$Password = ConvertTo-SecureString -String "mypasswd" -AsPlainText -Force
|
||||||
Mock Get-Credential {
|
Mock Get-Credential {
|
||||||
return [PSCustomObject]@{
|
return [PSCredential]::new($UserName, $Password)
|
||||||
UserName = 'myUser'
|
|
||||||
Password = ConvertTo-SecureString -String "mypasswd" -AsPlainText -Force
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
It "Missing CredentialStore should throw" {
|
It "Missing CredentialStore should throw" {
|
||||||
New-CredentialStoreItem -Path 'C:\missingStore.json' -RemoteHost 'notrelevant' | Should -Throw "Could not add anything"
|
New-CredentialStoreItem -Path 'C:\missingStore.json' -RemoteHost 'notrelevant' | Should -Throw "Could not add anything"
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user