pashage

Yet Another Opinionated Re-engineering of the Unix Password Store
git clone https://git.instinctive.eu/pashage.git
Log | Files | Refs | README | LICENSE

commit 61bde10c847f9b42789dd6d11b84612736a89de4
parent fe78a3e62d7d2578455a98deb158cc9158ea09a7
Author: Natasha Kerensikova <natgh@instinctive.eu>
Date:   Wed, 26 Nov 2025 20:11:42 +0000

Re-encryption recursion behavior is better tested
Diffstat:
Mspec/action_spec.sh | 61++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 60 insertions(+), 1 deletion(-)

diff --git a/spec/action_spec.sh b/spec/action_spec.sh @@ -2002,9 +2002,11 @@ Describe 'Action Functions' scm_commit() { mocklog scm_commit "$@"; } setup() { - @mkdir -p "${PREFIX}/subdir/subsub" + @mkdir -p "${PREFIX}/subdir/other" "${PREFIX}/subdir/subsub" + %putsn id >"${PREFIX}/subdir/other/.age-recipients" %putsn data >"${PREFIX}/root.age" %putsn data >"${PREFIX}/subdir/middle.age" + %putsn data >"${PREFIX}/subdir/other/unrelated.age" %putsn data >"${PREFIX}/subdir/subsub/deep.age" } @@ -2054,6 +2056,32 @@ Describe 'Action Functions' The error should equal "$(result)" End + It 'recursively and deeply re-encrypts a directory' + DECISION=default + RECURSIVE=yes + result() { + %text:expand + #|$ scm_begin + #|$ do_decrypt ${PREFIX}/subdir/middle.age + #|$ do_encrypt subdir/middle-XXXXXXXXX.age + #|$ mv -f -- ${PREFIX}/subdir/middle-XXXXXXXXX.age ${PREFIX}/subdir/middle.age + #|$ scm_add subdir/middle.age + #|$ do_decrypt ${PREFIX}/subdir/other/unrelated.age + #|$ do_encrypt subdir/other/unrelated-XXXXXXXXX.age + #|$ mv -f -- ${PREFIX}/subdir/other/unrelated-XXXXXXXXX.age ${PREFIX}/subdir/other/unrelated.age + #|$ scm_add subdir/other/unrelated.age + #|$ do_decrypt ${PREFIX}/subdir/subsub/deep.age + #|$ do_encrypt subdir/subsub/deep-XXXXXXXXX.age + #|$ mv -f -- ${PREFIX}/subdir/subsub/deep-XXXXXXXXX.age ${PREFIX}/subdir/subsub/deep.age + #|$ scm_add subdir/subsub/deep.age + #|$ scm_commit Re-encrypt subdir/ + } + When call do_reencrypt subdir/ + The status should be success + The output should be blank + The error should equal "$(result)" + End + It 'recursively re-encrypts the whole store as /' DECISION=default RECURSIVE=no @@ -2132,6 +2160,37 @@ Describe 'Action Functions' The error should equal "$(result)" End + It 'asks for confirmation before each file in deep re-encryption' + DECISION=interactive + RECURSIVE=yes + YESNO_NEXT=n + yesno() { + mocklog yesno "$@" + ANSWER="${YESNO_NEXT}" + YESNO_NEXT=y + } + result() { + %text:expand + #|$ scm_begin + #|$ yesno Re-encrypt subdir/middle? + #|$ yesno Re-encrypt subdir/other/unrelated? + #|$ do_decrypt ${PREFIX}/subdir/other/unrelated.age + #|$ do_encrypt subdir/other/unrelated-XXXXXXXXX.age + #|$ mv -f -- ${PREFIX}/subdir/other/unrelated-XXXXXXXXX.age ${PREFIX}/subdir/other/unrelated.age + #|$ scm_add subdir/other/unrelated.age + #|$ yesno Re-encrypt subdir/subsub/deep? + #|$ do_decrypt ${PREFIX}/subdir/subsub/deep.age + #|$ do_encrypt subdir/subsub/deep-XXXXXXXXX.age + #|$ mv -f -- ${PREFIX}/subdir/subsub/deep-XXXXXXXXX.age ${PREFIX}/subdir/subsub/deep.age + #|$ scm_add subdir/subsub/deep.age + #|$ scm_commit Re-encrypt subdir/ + } + When call do_reencrypt subdir + The status should be success + The output should be blank + The error should equal "$(result)" + End + It 'reports a non-existent directory' result() { %text