diff options
| author | Igor Soarez <igor@soarez.org> | 2026-11-22 07:19:58 +0000 |
|---|---|---|
| committer | Igor Soarez <igor@soarez.org> | 2026-11-22 07:19:58 +0000 |
| commit | 5b9baa9171f35872ab040b429c5ac5b1b6f74140 (patch) | |
| tree | 85c810e43d080539592713acffc7bbe237515e8f /secrets/test/list.sh | |
| parent | 990a23be281ee13e33c165f446d2ac3c0c88299c (diff) | |
szecret list: a bucket's store keys show at a terminal as one stores line, counted apart from its secrets; --names, --json and piped list unchangedHEADmaster
Diffstat (limited to 'secrets/test/list.sh')
| -rwxr-xr-x | secrets/test/list.sh | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/secrets/test/list.sh b/secrets/test/list.sh index cf07dd0..bd72f9a 100755 --- a/secrets/test/list.sh +++ b/secrets/test/list.sh @@ -179,6 +179,43 @@ test_list_reads_nothing() { pass "list: says what to do when this machine reads nothing" } +# A store's key shows as its store, apart from the secrets and their count; +# what scripts read still names the file. +test_list_stores() { + local out + echo v | szecret put mine/local-key-proj + echo v | szecret put mine/local-key-alpha + out="$(SZECRET_FORCE_TTY=80 szecret list)" + assert_contains "${out}" "mine 2 secrets, 2 stores" + assert_contains "${out}" " stores: alpha, proj" + assert_contains "${out}" " mine-a mine-b" + [[ "${out}" != *local-key-* ]] || fail "list shows a store's key as a secret: ${out}" + assert_contains "${out}" "me reads 2 buckets, 8 secrets, 2 stores" + assert_contains "$(SZECRET_FORCE_TTY=80 szecret list --all)" "me reads 2 of 4 buckets, 8 of 10 secrets, 2 of 2 stores" + out="$(SZECRET_FORCE_TTY=36 szecret list)" + assert_contains "${out}" "me reads 2 buckets, 8 secrets,"$'\n'" 2 stores" + assert_contains "$(szecret list --names)" "mine/local-key-proj" + assert_contains "$(szecret list)" "local-key-alpha" + assert_contains "$(szecret list --json)" '"secrets":["local-key-alpha","local-key-proj","mine-a","mine-b"]' + rm "${SZECRET_BUCKETS}/mine/local-key-alpha.age" "${SZECRET_BUCKETS}/mine/local-key-proj.age" + pass "list: store keys as one stores line, scripts still see the files" +} + +# A bucket holding only a store's key: no empty grid, no "0 secrets". +test_list_store_only() { + local out + mkdir -p "${SZECRET_BUCKETS}/storeonly" + printf '# me\n%s\n' "${me}" > "${SZECRET_BUCKETS}/storeonly/recipients" + szecret rekey --add-ok storeonly >/dev/null + echo v | szecret put storeonly/local-key-solo + out="$(SZECRET_FORCE_TTY=80 szecret list)" + assert_contains "${out}" "storeonly 1 store" + assert_contains "${out}" " stores: solo" + [[ "${out}" != *"0 secrets"* ]] || fail "list says 0 secrets: ${out}" + rm -r "${SZECRET_BUCKETS}/storeonly" + pass "list: a bucket holding only a store's key" +} + run_tests() { test_list_empty_store test_list_shows_secrets @@ -189,6 +226,8 @@ run_tests() { test_list_terminal_all_and_keys test_list_narrow test_list_json + test_list_stores + test_list_store_only test_list_problems test_list_reads_nothing } |
