diff options
| author | Igor Soarez <igor@soarez.org> | 2026-11-18 14:02:09 +0000 |
|---|---|---|
| committer | Igor Soarez <igor@soarez.org> | 2026-11-18 14:02:09 +0000 |
| commit | 8f818a64f2f0f3a833fc842d52a675358ec64c9c (patch) | |
| tree | eac13a48cada4595c9073d62060c1145189c6344 /secrets/test/rotate.sh | |
| parent | 6444d6a508cdfdcf52cc6c83bab1e29a7e2a2e10 (diff) | |
szecret: buckets beside the old store -- get/has/put/mv/rekey/list/check/enrol, admins from SZECRET_ADMINS_COMMAND; rotate retired (fleet hardening 12)
A bucket is a directory of secrets with one set of readers: its recipients file plus the admins, the full set recorded in .szecret by rekey. put refuses when the readers or admins drift from that set, or with no admins; a plain put of a new name goes to admin-only, one still in the old store is rewritten there. The old store keeps working throughout. link/claude.sh leaves out an MCP server whose secret is in a bucket this host doesn't read. Design: cloud-setup docs/proposal-secret-roles.md.
Diffstat (limited to 'secrets/test/rotate.sh')
| -rwxr-xr-x | secrets/test/rotate.sh | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/secrets/test/rotate.sh b/secrets/test/rotate.sh deleted file mode 100755 index 02abe39..0000000 --- a/secrets/test/rotate.sh +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/bash -# Tests for rotate command - -this_dir="$(cd "$(dirname "$0")" && pwd)" -source "${this_dir}/common.sh" - -setup_key_dir_layout() { - local keys_dir="${TEST_DIR}/keys" - mkdir -p "${keys_dir}" "${SZECRET_STORE}" - rm -f "${SZECRET_STORE}"/*.age - unset SZECRET_PRIVATE_KEY - export SZECRET_PRIVATE_KEY_DIR="${keys_dir}" - - local temp_key="${TEST_DIR}/initial-key" - age-keygen -o "${temp_key}" 2>/dev/null - local pub - pub="$(age-keygen -y "${temp_key}")" - echo "${pub}" > "${SZECRET_PUBLIC_KEY}" - mv "${temp_key}" "${keys_dir}/${pub}" - chmod 600 "${keys_dir}/${pub}" - SETUP_PUB="${pub}" -} - -test_rotate_reencrypts_secrets() { - setup_key_dir_layout - local old_pub="${SETUP_PUB}" - - echo "rotate-me" | szecret put "rotate-test" - echo "other" | szecret put "rotate-other" - - szecret rotate --yes - - local new_pub - new_pub="$(cat "${SZECRET_PUBLIC_KEY}")" - if [[ "${new_pub}" == "${old_pub}" ]]; then - fail "public key should change after rotate" - fi - - assert_equals "rotate-me" "$(szecret get "rotate-test")" "rotated secret" - assert_equals "other" "$(szecret get "rotate-other")" "other rotated secret" - assert_file_exists "${SZECRET_PRIVATE_KEY_DIR}/${new_pub}" "new private key file" - pass "rotate re-encrypts secrets and updates keys" -} - -test_rotate_empty_store() { - setup_key_dir_layout >/dev/null - - szecret rotate --yes - - local new_pub - new_pub="$(cat "${SZECRET_PUBLIC_KEY}")" - assert_file_exists "${SZECRET_PRIVATE_KEY_DIR}/${new_pub}" "new private key with empty store" - pass "rotate succeeds with empty store" -} - -test_rotate_requires_confirmation() { - setup_key_dir_layout >/dev/null - - assert_failure szecret rotate - pass "rotate fails without confirmation" -} - -run_tests() { - test_rotate_reencrypts_secrets - test_rotate_empty_store - test_rotate_requires_confirmation -} - -[[ "${BASH_SOURCE[0]}" == "${0}" ]] && run_tests |
