2022-07-14 13:37:12 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
2019-01-16 12:55:29 +01:00
|
|
|
|
|
|
|
Describe "Test-CredentialStore" {
|
|
|
|
Context "Basic logic tests" {
|
2022-07-14 13:37:12 +02:00
|
|
|
It "Should Not Throw" {
|
|
|
|
$TestCredentialStore = './resources/cs/CredentialStore.json'
|
2019-01-16 12:55:29 +01:00
|
|
|
{ Test-CredentialStore -Shared -Path $TestCredentialStore } | Should -Not -Throw
|
|
|
|
}
|
2022-07-14 13:37:12 +02:00
|
|
|
It "Read valid CredentialStore" {
|
|
|
|
$TestCredentialStore = './resources/cs/CredentialStore.json'
|
2019-01-16 12:55:29 +01:00
|
|
|
$res = Test-CredentialStore -Shared -Path $TestCredentialStore
|
|
|
|
$res | Should -Be $true
|
|
|
|
}
|
2022-07-14 13:37:12 +02:00
|
|
|
It "Read a broken CredentialStore" -Skip {
|
|
|
|
$BrokenCS = './resources/cs/Broken_CS.json'
|
2019-01-16 12:55:29 +01:00
|
|
|
$oWarningPreference = $WarningPreference
|
|
|
|
$WarningPreference = 'SilentlyContinue'
|
|
|
|
$res = Test-CredentialStore -Shared -Path $BrokenCS
|
|
|
|
$res | Should -Be $false
|
|
|
|
$WarningPreference = $oWarningPreference
|
|
|
|
}
|
2022-07-14 13:37:12 +02:00
|
|
|
It "Not existing path should return false" {
|
2019-01-16 12:55:29 +01:00
|
|
|
if ($isWindows -or ($PSVersionTable.PSVersion.Major -eq 5)) {
|
|
|
|
Test-CredentialStore -Shared -Path 'C:\foobar\CredentialStore.json' | Should -Be $false
|
|
|
|
}
|
|
|
|
elseif ($isWindows -or $IsMacOS) {
|
|
|
|
Test-CredentialStore -Shared -Path '/var/opt/foo.json' | Should -Be $false
|
|
|
|
}
|
|
|
|
}
|
2022-07-14 13:37:12 +02:00
|
|
|
It "testing private CredentialStore path" {
|
2019-01-16 12:55:29 +01:00
|
|
|
if (Test-Path -Path (Get-DefaultCredentialStorePath)) {
|
|
|
|
Remove-Item -Path (Get-DefaultCredentialStorePath)
|
|
|
|
}
|
|
|
|
Test-CredentialStore | Should -Be $false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|