Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
94711cafb2 |
No files matched your search
@@ -30,11 +30,7 @@ var (
|
|||||||
errFilesFailedRestore = errors.New("file(s) failed to restore")
|
errFilesFailedRestore = errors.New("file(s) failed to restore")
|
||||||
errPathsNotInSnapshot = errors.New("requested path(s) not in the snapshot")
|
errPathsNotInSnapshot = errors.New("requested path(s) not in the snapshot")
|
||||||
errFilesFailedVerify = errors.New("files failed verification")
|
errFilesFailedVerify = errors.New("files failed verification")
|
||||||
errDecryptionKeyRequired = errors.New(
|
errDecryptionKeyRequired = errors.New(ageSecretKeyMissingMessage)
|
||||||
"decryption key required for restore\n\n" +
|
|
||||||
"Set the VAULTIK_AGE_SECRET_KEY environment variable to your " +
|
|
||||||
"age private key file:\n" +
|
|
||||||
" export VAULTIK_AGE_SECRET_KEY=\"$(cat vaultik_backup_private_key.txt)\"")
|
|
||||||
// errInvalidAgeSecretKey is returned when the configured key does not
|
// errInvalidAgeSecretKey is returned when the configured key does not
|
||||||
// parse as any age identity. It names the source but never the value,
|
// parse as any age identity. It names the source but never the value,
|
||||||
// which is secret, so the message is safe to print and log.
|
// which is secret, so the message is safe to print and log.
|
||||||
|
|||||||
@@ -106,3 +106,18 @@ func TestRestoreIdentitiesMissingKey(t *testing.T) {
|
|||||||
_, err := v.restoreIdentities()
|
_, err := v.restoreIdentities()
|
||||||
require.ErrorIs(t, err, errDecryptionKeyRequired)
|
require.ErrorIs(t, err, errDecryptionKeyRequired)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestMissingKeyErrorsNameBothSources asserts the missing-key errors for
|
||||||
|
// restore and deep verify say the key is missing and name both places it
|
||||||
|
// can be set, the environment variable first since it is preferred, with
|
||||||
|
// the same wording in both.
|
||||||
|
func TestMissingKeyErrorsNameBothSources(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
const want = "age secret key is missing; set it in " +
|
||||||
|
"the VAULTIK_AGE_SECRET_KEY environment variable or the " +
|
||||||
|
"age_secret_key config file field"
|
||||||
|
|
||||||
|
require.Equal(t, want, errSecretKeyRequired.Error())
|
||||||
|
require.Equal(t, want, errDecryptionKeyRequired.Error())
|
||||||
|
}
|
||||||
@@ -20,11 +20,18 @@ import (
|
|||||||
"sneak.berlin/go/vaultik/internal/storage"
|
"sneak.berlin/go/vaultik/internal/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ageSecretKeyMissingMessage is the shared text of the missing-key errors
|
||||||
|
// for restore and deep verify. It says the key is missing and names both
|
||||||
|
// places it can come from, the environment variable first since it is
|
||||||
|
// preferred.
|
||||||
|
const ageSecretKeyMissingMessage = "age secret key is missing; set it in " +
|
||||||
|
"the VAULTIK_AGE_SECRET_KEY environment variable or the " +
|
||||||
|
"age_secret_key config file field"
|
||||||
|
|
||||||
// Sentinel errors for snapshot verification failures.
|
// Sentinel errors for snapshot verification failures.
|
||||||
var (
|
var (
|
||||||
errVerificationFailed = errors.New("verification failed")
|
errVerificationFailed = errors.New("verification failed")
|
||||||
errSecretKeyRequired = errors.New(
|
errSecretKeyRequired = errors.New(ageSecretKeyMissingMessage)
|
||||||
"VAULTIK_AGE_SECRET_KEY not set; required for deep verification")
|
|
||||||
errChunksOutOfOrder = errors.New("chunks out of order")
|
errChunksOutOfOrder = errors.New("chunks out of order")
|
||||||
errChunkHashMismatch = errors.New("chunk hash mismatch")
|
errChunkHashMismatch = errors.New("chunk hash mismatch")
|
||||||
errNegativeChunkLength = errors.New("chunk length is negative")
|
errNegativeChunkLength = errors.New("chunk length is negative")
|
||||||
|
|||||||
Reference in new issue
Block a user