Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f3baf2b31d |
@@ -721,8 +721,7 @@ func (cli *Instance) addPGPUnlocker(cmd *cobra.Command) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnlockersRemove removes an unlocker, holding the state directory lock
|
// UnlockersRemove removes an unlocker with safety checks
|
||||||
// while removeUnlocker runs
|
|
||||||
func (cli *Instance) UnlockersRemove(
|
func (cli *Instance) UnlockersRemove(
|
||||||
unlockerID string, force bool, cmd *cobra.Command,
|
unlockerID string, force bool, cmd *cobra.Command,
|
||||||
) error {
|
) error {
|
||||||
@@ -732,13 +731,6 @@ func (cli *Instance) UnlockersRemove(
|
|||||||
}
|
}
|
||||||
defer release()
|
defer release()
|
||||||
|
|
||||||
return cli.removeUnlocker(unlockerID, force, cmd)
|
|
||||||
}
|
|
||||||
|
|
||||||
// removeUnlocker removes an unlocker with safety checks
|
|
||||||
func (cli *Instance) removeUnlocker(
|
|
||||||
unlockerID string, force bool, cmd *cobra.Command,
|
|
||||||
) error {
|
|
||||||
// Get current vault
|
// Get current vault
|
||||||
vlt, err := vault.GetCurrentVault(cli.fs, cli.stateDir)
|
vlt, err := vault.GetCurrentVault(cli.fs, cli.stateDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -6,11 +6,6 @@
|
|||||||
// have a long-term key?) each look at the vault on disk before acting.
|
// have a long-term key?) each look at the vault on disk before acting.
|
||||||
// When that look fails they must refuse to act, not read the failure as
|
// When that look fails they must refuse to act, not read the failure as
|
||||||
// "nothing there" and go ahead.
|
// "nothing there" and go ahead.
|
||||||
//
|
|
||||||
// The tests make the look fail with a wrapper around the in-memory
|
|
||||||
// filesystem, which the state directory lock refuses. So they call the
|
|
||||||
// function each command runs once it holds the lock, such as removeVault
|
|
||||||
// for RemoveVault.
|
|
||||||
|
|
||||||
//nolint:testpackage // white-box test of unexported internals
|
//nolint:testpackage // white-box test of unexported internals
|
||||||
package cli
|
package cli
|
||||||
@@ -247,7 +242,7 @@ func TestRemoveLastUnlockerAbortsWhenSecretsUnreadable(t *testing.T) {
|
|||||||
writeTestSecret(t, base, vaultDir)
|
writeTestSecret(t, base, vaultDir)
|
||||||
instance, cmd := newTestInstance(&statFailFs{Fs: base, path: path})
|
instance, cmd := newTestInstance(&statFailFs{Fs: base, path: path})
|
||||||
|
|
||||||
err := instance.removeUnlocker(
|
err := instance.UnlockersRemove(
|
||||||
"pgp-"+listTestGPGKeyID+"A", false, cmd)
|
"pgp-"+listTestGPGKeyID+"A", false, cmd)
|
||||||
|
|
||||||
require.ErrorIs(t, err, errStatFailed)
|
require.ErrorIs(t, err, errStatFailed)
|
||||||
@@ -294,7 +289,7 @@ func TestRemoveVaultAbortsWhenSecretsDirUnreadable(t *testing.T) {
|
|||||||
writeTestSecret(t, base, vaultDir)
|
writeTestSecret(t, base, vaultDir)
|
||||||
instance, cmd := newTestInstance(tt.failFs(base))
|
instance, cmd := newTestInstance(tt.failFs(base))
|
||||||
|
|
||||||
err := instance.removeVault(cmd, unreadableTestOtherVault, false)
|
err := instance.RemoveVault(cmd, unreadableTestOtherVault, false)
|
||||||
|
|
||||||
require.ErrorIs(t, err, tt.wantErr)
|
require.ErrorIs(t, err, tt.wantErr)
|
||||||
|
|
||||||
@@ -316,7 +311,7 @@ func TestVaultImportAbortsWhenPubKeyUnreadable(t *testing.T) {
|
|||||||
Fs: base, path: filepath.Join(testVaultDir(listTestVaultName), "pub.age"),
|
Fs: base, path: filepath.Join(testVaultDir(listTestVaultName), "pub.age"),
|
||||||
})
|
})
|
||||||
|
|
||||||
err := instance.importMnemonic(cmd, listTestVaultName)
|
err := instance.VaultImport(cmd, listTestVaultName)
|
||||||
|
|
||||||
require.ErrorIs(t, err, errStatFailed)
|
require.ErrorIs(t, err, errStatFailed)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -613,8 +613,7 @@ func (cli *Instance) switchAwayFromVault(
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveVault removes a vault, holding the state directory lock while
|
// RemoveVault removes a vault with safety checks
|
||||||
// removeVault runs
|
|
||||||
func (cli *Instance) RemoveVault(cmd *cobra.Command, name string, force bool) error {
|
func (cli *Instance) RemoveVault(cmd *cobra.Command, name string, force bool) error {
|
||||||
release, err := vault.LockStateDir(cli.fs, cli.stateDir)
|
release, err := vault.LockStateDir(cli.fs, cli.stateDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -622,11 +621,6 @@ func (cli *Instance) RemoveVault(cmd *cobra.Command, name string, force bool) er
|
|||||||
}
|
}
|
||||||
defer release()
|
defer release()
|
||||||
|
|
||||||
return cli.removeVault(cmd, name, force)
|
|
||||||
}
|
|
||||||
|
|
||||||
// removeVault removes a vault with safety checks
|
|
||||||
func (cli *Instance) removeVault(cmd *cobra.Command, name string, force bool) error {
|
|
||||||
// Get list of all vaults
|
// Get list of all vaults
|
||||||
vaults, err := vault.ListVaults(cli.fs, cli.stateDir)
|
vaults, err := vault.ListVaults(cli.fs, cli.stateDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user