Tests/Register-ChromiumSecretVault.Tests.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#requires -modules @{ModuleName="Pester"; ModuleVersion="5.1.0"}
Describe 'Register-ChromiumSecretVault' {
    BeforeAll {
        Import-Module $PSScriptRoot/.. -Force -Verbose
    }
    AfterAll {
        Remove-Module SecretManagement.Chromium -Force
    }

    It 'Registers Chrome Preset Vault' {
        Register-ChromiumSecretVault -Preset Chrome
    }
    It 'Registers Chrome Preset Vault w/ AllowClobber' {
        Get-SecretVault 'Chrome' -ErrorAction SilentlyContinue | Unregister-SecretVault -ErrorAction SilentlyContinue
        if (Get-SecretVault 'Chrome' -ErrorAction SilentlyContinue) {throw 'Cannot proceed because a vault with same name could not be cleaned up'}
        Register-ChromiumSecretVault -Preset Chrome
        Register-ChromiumSecretVault -Preset Chrome -AllowClobber
        $chromeVault = Get-SecretVault 'Chrome'
        $chromeVault.VaultParameters.DataPath | Should -Exist
        $chromeVault.VaultParameters.StatePath | Should -Exist
        $chromeVault.Name | Should -Be 'Chrome'
    }
    It 'Registers All Vaults' {
        Register-ChromiumSecretVault -WarningAction SilentlyContinue
        Register-ChromiumSecretVault -AllowClobber
    }
}