From 642af42d7e6d9d470cc51d1b5ad421fdea8e8243 Mon Sep 17 00:00:00 2001 From: OCram85 Date: Fri, 1 Jul 2022 11:27:28 +0200 Subject: [PATCH] wip --- src/Store/Get-CredentialStore.Tests.ps1 | 4 ++-- src/Store/New-CredentialStore.Tests.ps1 | 26 ++++++++++++++----------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/Store/Get-CredentialStore.Tests.ps1 b/src/Store/Get-CredentialStore.Tests.ps1 index 25a7fae..bb940a0 100644 --- a/src/Store/Get-CredentialStore.Tests.ps1 +++ b/src/Store/Get-CredentialStore.Tests.ps1 @@ -13,7 +13,7 @@ BeforeAll { Describe "Get-CredentialStore" { Context "Basic logic tests" { - It "Test1: Read CS without params" { + It "Read CS without params" { $TestCredentialStore = './resources/cs/CredentialStore.json' $TestPfxCert = './resources/cs/PSCredentialStore.pfx' if (! (Test-Path -Path (Get-DefaultCredentialStorePath)) ) { @@ -21,7 +21,7 @@ Describe "Get-CredentialStore" { } { Get-CredentialStore } | Should -Not -Throw } - It "Test2: Read Credential Store with testing data" { + It "Read Credential Store with testing data" { $TestCredentialStore = './resources/cs/CredentialStore.json' $TestPfxCert = './resources/cs/PSCredentialStore.pfx' { diff --git a/src/Store/New-CredentialStore.Tests.ps1 b/src/Store/New-CredentialStore.Tests.ps1 index f660240..9cc5b88 100644 --- a/src/Store/New-CredentialStore.Tests.ps1 +++ b/src/Store/New-CredentialStore.Tests.ps1 @@ -34,17 +34,17 @@ BeforeAll { Describe "New-CredentialStore" { Context "Private CS tests" { - It "Test1: Create new private CredentialStore" { + It "Create new private CredentialStore" { $pCS = Get-DefaultCredentialStorePath { New-CredentialStore -Confirm:$false -Force } | Should -Not -Throw $result = Test-Path -Path $pCS $CS = Get-Content -Path $pCS -Raw | ConvertFrom-Json ($result -eq $true) -and ($CS.Type -eq "Private") | Should -Be $true } - It "Test2: Try to override private Store" { + It "Try to override private Store" { { New-CredentialStore -Confirm:$false } | Should -Throw } - It "Test3: Reset existing Credential Store" { + It "Reset existing Credential Store" { $pCS = Get-DefaultCredentialStorePath $now = Get-Date $CS = Get-Content -Path $pCS -Raw | ConvertFrom-Json @@ -54,15 +54,15 @@ Describe "New-CredentialStore" { } } Context "Shared CS tests" { - It "Test1: Create a new Shared Credential Store" { + It "Create a new Shared Credential Store" { $sCS = Get-DefaultCredentialStorePath -Shared { New-CredentialStore -Confirm:$false -Shared } | Should -Not -Throw Test-Path -Path $sCS | Should -Be $true } - It "Test2: Try to override existing shared CS" { + It "Try to override existing shared CS" { { New-CredentialStore -Shared -Confirm:$false } | Should -Throw } - It "Test3: Reset shared CredentialStore" { + It "Reset shared CredentialStore" { $sCS = Get-DefaultCredentialStorePath -Shared $now = Get-Date $CS = Get-Content -Path $sCS -Raw | ConvertFrom-Json @@ -72,15 +72,15 @@ Describe "New-CredentialStore" { } } Context "Custom Shared CS tests" { - It "Test1: Create new custom shared" { + It "Create new custom shared" { $cCS = Join-Path -Path (Get-TempDir) -ChildPath "CredentialStore.json" - { New-CredentialStore -Path $cCS -Shared -Confirm:$false } | Should -Not -Throw + { New-CredentialStore -Path $cCS -Shared -Confirm:$false -SkipPFXCertCreation } | Should -Not -Throw } - It "Test2: Try to override exiting one" { + It "Try to override exiting one" { $cCS = Join-Path -Path (Get-TempDir) -ChildPath "CredentialStore.json" { New-CredentialStore -Path $cCS -Shared -Confirm:$false } | Should -Throw } - It "Test3: Reset existing custom CredentialStore" { + It "Reset existing custom CredentialStore" { $cCS = Join-Path -Path (Get-TempDir) -ChildPath "CredentialStore.json" { New-CredentialStore -Path $cCS -Shared -Force -Confirm:$false } | Should -Not -Throw } @@ -88,7 +88,11 @@ Describe "New-CredentialStore" { Context "Test exception handling" { Mock Out-File { throw "foobar exception" } It "JSON Conversion should fail and throw" { - { New-CredentialStore -Path (Join-Path -Path (Get-TempDir) -ChildPath '/dummy.json') -Shared -Confirm:$false } | Should -Throw + { + New-CredentialStore -Path ( + Join-Path -Path (Get-TempDir) -ChildPath '/dummy.json' + ) -Shared -Confirm:$false + } | Should -Throw } } Context "Tests for Windows certificate store" {