adds CredentialStore related Pester tests
This commit is contained in:
parent
6e442af8a4
commit
323ab64226
37
tests/Store/00_Get-CredentialStore.Tests.ps1
Normal file
37
tests/Store/00_Get-CredentialStore.Tests.ps1
Normal file
@ -0,0 +1,37 @@
|
||||
#region HEADER
|
||||
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
# $RepoRoot = (Get-Item -Path $here).Parent.Parent.FullName
|
||||
$RepoRoot = (Get-GitDirectory).replace('\.git', '')
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.'
|
||||
$sut = $sut -replace "\d{2}`_", ''
|
||||
$suthome = (Get-ChildItem -Path $RepoRoot -Exclude ".\tests\" -Filter $sut -Recurse).FullName
|
||||
# Skip try loading the source file if it doesn't exists.
|
||||
If ($suthome.Length -gt 0) {
|
||||
. $suthome
|
||||
}
|
||||
Else {
|
||||
Write-Warning ("Could not find source file {0}" -f $sut)
|
||||
}
|
||||
|
||||
# load additional functions defined in the repository. Replace the expression <FunctionName>.
|
||||
# . (Get-ChildItem -Path $RepoRoot -Filter "<Function-Name>.ps1" -Recurse).FullName
|
||||
|
||||
#endregion HEADER
|
||||
|
||||
Describe "Get-CredentialStore" {
|
||||
Context "Basic logic tests" {
|
||||
$TestCredentialStore = Resolve-Path -Path ("{0}\resources\cs\CredentialStore.json" -f $RepoRoot)
|
||||
It "Test1: Read CS without params" {
|
||||
If (Test-Path -Path ("{0}\CredentialStore.json" -f $env:APPDATA)) {
|
||||
{Get-CredentialStore} | Should Not Throw
|
||||
}
|
||||
Else {
|
||||
Write-Warning "Default private Credential Store not found. Skipping..."
|
||||
}
|
||||
}
|
||||
It "Test2: Read Credential Store with testing data" {
|
||||
|
||||
{Get-CredentialStore -Path $TestCredentialStore} | Should Not Throw
|
||||
}
|
||||
}
|
||||
}
|
40
tests/Store/00_Test-CredentialStore.Tests.ps1
Normal file
40
tests/Store/00_Test-CredentialStore.Tests.ps1
Normal file
@ -0,0 +1,40 @@
|
||||
#region HEADER
|
||||
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
# $RepoRoot = (Get-Item -Path $here).Parent.Parent.FullName
|
||||
$RepoRoot = (Get-GitDirectory).replace('\.git', '')
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.'
|
||||
$sut = $sut -replace "\d{2}`_", ''
|
||||
$suthome = (Get-ChildItem -Path $RepoRoot -Exclude ".\tests\" -Filter $sut -Recurse).FullName
|
||||
# Skip try loading the source file if it doesn't exists.
|
||||
If ($suthome.Length -gt 0) {
|
||||
. $suthome
|
||||
}
|
||||
Else {
|
||||
Write-Warning ("Could not find source file {0}" -f $sut)
|
||||
}
|
||||
|
||||
# load additional functions defined in the repository. Replace the expression <FunctionName>.
|
||||
# . (Get-ChildItem -Path $RepoRoot -Filter "<Function-Name>.ps1" -Recurse).FullName
|
||||
|
||||
#endregion HEADER
|
||||
|
||||
Describe "Test-CredentialStore" {
|
||||
Context "Basic logic tests" {
|
||||
$TestCredentialStore = Resolve-Path -Path ("{0}\resources\cs\CredentialStore.json" -f $RepoRoot)
|
||||
It "Test1: Should Not Throw" {
|
||||
{ Test-CredentialStore -Path $TestCredentialStore } | Should Not Throw
|
||||
}
|
||||
It "Test2: Read valid CredentialStore" {
|
||||
$res = Test-CredentialStore -Path $TestCredentialStore
|
||||
$res | Should Be $True
|
||||
}
|
||||
It "Test3: Read a broken CredentialStore" {
|
||||
$BrokenCS = Resolve-Path -Path ("{0}\resources\cs\Broken_CS.json" -f $RepoRoot)
|
||||
$oWarningPreference = $WarningPreference
|
||||
$WarningPreference = 'SilentlyContinue'
|
||||
$res = Test-CredentialStore -Path $BrokenCS
|
||||
$res | Should Be $False
|
||||
$WarningPreference = $oWarningPreference
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user