diff options
| -rw-r--r-- | secrets/common.sh | 6 | ||||
| -rwxr-xr-x | secrets/test/buckets.sh | 13 |
2 files changed, 16 insertions, 3 deletions
diff --git a/secrets/common.sh b/secrets/common.sh index 5eee8b6..b839cef 100644 --- a/secrets/common.sh +++ b/secrets/common.sh @@ -164,11 +164,11 @@ local_key_name() { ensure_local_store() { local local_store_name="$1" local local_key_name - local local_key_file local_key_name="$(local_key_name "${local_store_name}")" - local_key_file="$(file_for "${local_key_name}")" - if ! [[ -r "${local_key_file}" ]]; then + # Wherever its key is, the old store or a bucket; whether this machine can + # open it is get's to say. + if ! (find_secret "${local_key_name}" >/dev/null 2>&1); then >&2 echo "ERROR: Local store '${local_store_name}' does not exist (key: ${local_key_name})" exit 1 fi diff --git a/secrets/test/buckets.sh b/secrets/test/buckets.sh index b021c3c..2703952 100755 --- a/secrets/test/buckets.sh +++ b/secrets/test/buckets.sh @@ -245,6 +245,18 @@ test_check_missing_plugin() { pass "check: flags a key type this machine can't encrypt to" } +test_local_store_key_in_bucket() { + local d="${TEST_DIR}/repo-store" + mkdir -p "${d}" + SZECRET_BUCKETS="" szecret create-local inrepo "${d}" >/dev/null 2>&1 || fail "create-local" + echo "local1" | szecret put-local "${d}/v.age" 2>/dev/null || fail "put-local before the move" + szecret mv local-key-inrepo mine 2>/dev/null || fail "mv local-key-inrepo" + assert_equals "local1" "$(szecret get-local "${d}/v.age")" "get-local with its key in a bucket" + echo "local2" | szecret put-local "${d}/v.age" 2>/dev/null || fail "put-local after the move" + assert_equals "local2" "$(szecret get-local "${d}/v.age")" "put-local with its key in a bucket" + pass "get-local/put-local: an old-style repository store whose key moved to a bucket" +} + test_ready() { szecret ready || fail "ready with an identity" SZECRET_STORE="" SZECRET_PRIVATE_KEY="${TEST_DIR}/none" szecret ready || fail "ready with only buckets and an identity" @@ -269,6 +281,7 @@ test_no_admins test_admin_change_needs_rekey test_list test_check_ok +test_local_store_key_in_bucket test_check_stanza_types test_check_missing_plugin test_ready |
