This commit is contained in:
OCram85 2022-06-28 11:24:31 +02:00
parent b9ebc2ab6e
commit 8808f1c70b

View File

@ -1,6 +1,19 @@
BeforeAll {
$ManifestFile = (Get-Item -Path "./src/*.psd1").FullName
Import-Module $ManifestFile -Force
$PrivateFunctions = (Get-ChildItem -Path "./src/Private/*.ps1" | Where-Object {
$_.BaseName -notmatch '.Tests'
}
).FullName
foreach ( $func in $PrivateFunctions) {
. $func
}
}
Describe "New-CredentialStoreItem" { Describe "New-CredentialStoreItem" {
Context "Private Credential Store tests" { Context "Private Credential Store tests" {
It "Test1: Add entry to existing private store." { It "Add entry to existing private store." {
# Creat a fresh CredentialStore first # Creat a fresh CredentialStore first
New-CredentialStore -Force New-CredentialStore -Force
@ -20,7 +33,7 @@ Describe "New-CredentialStoreItem" {
} }
} }
Context "Test with new shared Credential Store" { Context "Test with new shared Credential Store" {
It "Test2: Create new RemoteHost entry" { It "Create new RemoteHost entry" {
# prepare test environment # prepare test environment
$tmpCS = Join-Path -Path (Get-TempDir) -ChildPath '/CredentialStore.json' $tmpCS = Join-Path -Path (Get-TempDir) -ChildPath '/CredentialStore.json'
New-CredentialStore -Shared -Path $tmpCS -Force New-CredentialStore -Shared -Path $tmpCS -Force
@ -48,7 +61,6 @@ Describe "New-CredentialStoreItem" {
} }
} }
Context "Test optional parameter lookup" { Context "Test optional parameter lookup" {
It "Test missing Credential" { It "Test missing Credential" {
function global:Get-Credential ([string]$Message) { function global:Get-Credential ([string]$Message) {
$UserName = 'testuser' $UserName = 'testuser'
@ -65,7 +77,7 @@ Describe "New-CredentialStoreItem" {
} }
Context "General Exception handling" { Context "General Exception handling" {
Mock Test-CredentialStore { return $false } Mock Test-CredentialStore { return $false } -ModuleName 'PSCredentialStore'
It "Missing CredentialStore should throw" { It "Missing CredentialStore should throw" {
{ New-CredentialStoreItem -Shared -Path 'C:\missingStore.json' -RemoteHost 'notrelevant' } | Should -Throw "Could not add anything" { New-CredentialStoreItem -Shared -Path 'C:\missingStore.json' -RemoteHost 'notrelevant' } | Should -Throw "Could not add anything"
} }