summaryrefslogtreecommitdiff
path: root/secrets
diff options
context:
space:
mode:
authorIgor Soarez <igor@soarez.org>2026-11-18 17:34:25 +0000
committerIgor Soarez <igor@soarez.org>2026-11-18 17:34:25 +0000
commit9249082857d407dde4e22e672b615631a294279e (patch)
treec5f8ce2e90b5172dbe3dab557e03d9ba6dbc4971 /secrets
parentbb723d867c380ef56917dc4c7836d33b940c6a69 (diff)
szecret get-local/put-local: find the store's key in a bucket too, not only in the old store
Diffstat (limited to 'secrets')
-rw-r--r--secrets/common.sh6
-rwxr-xr-xsecrets/test/buckets.sh13
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