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 8cfd312b56e4d958f60cd9de133ab28574edc439
parent 7ea4c34c68e07b6b7031ef4c6afcb085e66d93fc
Author: Natasha Kerensikova <natgh@instinctive.eu>
Date:   Sun, 22 Sep 2024 10:44:09 +0000

pass-like script is identified by its name rather than its path
Diffstat:
Mspec/pass_spec.sh | 118++++++++++++++++++++++++++++++++++++++++----------------------------------------
1 file changed, 59 insertions(+), 59 deletions(-)

diff --git a/spec/pass_spec.sh b/spec/pass_spec.sh @@ -34,7 +34,7 @@ End Describe 'Pass-like command' check_skip() { - [ "$1" = "${1%pass}pass" ] && ! [ "${SHELLSPEC_SHELL_TYPE}" = bash ] + [ -z "${1%%pass*}" ] && ! [ "${SHELLSPEC_SHELL_TYPE}" = bash ] } GITLOG="${SHELLSPEC_WORKDIR}/git-log.txt" @@ -288,7 +288,7 @@ Describe 'Pass-like command' Describe 'init' It 're-encrypts the whole store using a new recipient id' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 init 'new-id' The output should include 'Password store' expected_log() { @@ -321,7 +321,7 @@ Describe 'Pass-like command' End It 're-encrypts a subdirectory using a new recipient id' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 init -p subdir 'new-id' The output should start with 'Password store' The output should include 'subdir' @@ -351,7 +351,7 @@ Describe 'Pass-like command' End It 're-encrypts a subdirectory after replacing recipient ids' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 init -p fluff 'new-id' 'new-master' The output should start with 'Password store' The output should include 'fluff' @@ -385,7 +385,7 @@ Describe 'Pass-like command' End It 're-encrypts a subdirectory after removing dedicated recipient ids' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 init -p fluff '' The status should be successful expected_log() { @@ -420,28 +420,28 @@ Describe 'Pass-like command' Describe 'ls' It 'lists a directory' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 ls subdir The line 1 of output should include 'subdir' The line 2 of output should include 'file' End It 'lists a directory implicitly' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 subdir The line 1 of output should include 'subdir' The line 2 of output should include 'file' End It 'lists a directory when called as `show`' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 show subdir The line 1 of output should include 'subdir' The line 2 of output should include 'file' End It 'lists the whole store without argument' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 The line 1 of output should equal 'Password Store' The line 2 of output should include 'extra' @@ -464,7 +464,7 @@ Describe 'Pass-like command' End It 'does not list a file masquerading as a directory' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 subdir/file/ The status should equal 1 The error should equal 'Error: subdir/file/ is not in the password store.' @@ -473,7 +473,7 @@ Describe 'Pass-like command' Describe 'find' It 'lists entries matching a substring' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 find o The lines of output should equal 6 The line 1 of output should match pattern 'Search *: o' @@ -485,7 +485,7 @@ Describe 'Pass-like command' End It 'reports success even without match' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 find z The status should be success The lines of output should equal 1 @@ -496,26 +496,26 @@ Describe 'Pass-like command' Describe 'show' It 'decrypts a password file' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 show subdir/file The output should equal 'p4ssw0rd' End It 'decrypts a password file implicitly' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 subdir/file The output should equal 'p4ssw0rd' End It 'decrypts a password file even when called as `list`' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 ls subdir/file The output should equal 'p4ssw0rd' End It 'displays the password as a QR-code' DISPLAY=mock - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 -q fluff/one expected_err() { %text:expand #|$ feh -x --title ${1}: fluff/one -g +200+200 - @@ -527,7 +527,7 @@ Describe 'Pass-like command' It 'displays the given line as a QR-code' DISPLAY=mock - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 --qrcode=2 fluff/three expected_err() { %text:expand #|$ feh -x --title ${1}: fluff/three -g +200+200 - @@ -539,7 +539,7 @@ Describe 'Pass-like command' It 'pastes into the clipboard' DISPLAY=mock - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 show -c fluff/three The output should start with \ 'Copied fluff/three to clipboard. Will clear in 45 seconds.' @@ -553,7 +553,7 @@ Describe 'Pass-like command' It 'pastes a selected line into the clipboard' DISPLAY=mock - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 show -c2 fluff/three The output should start with \ 'Copied fluff/three to clipboard. Will clear in 45 seconds.' @@ -568,7 +568,7 @@ Describe 'Pass-like command' Describe 'grep' It 'shows decrypted lines matching a regex' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 grep -i Com The lines of output should equal 4 The line 1 of output should include 'fluff' @@ -580,7 +580,7 @@ Describe 'Pass-like command' End It 'is successful even without match' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 grep nothing.matches The status should be success The output should be blank @@ -589,7 +589,7 @@ Describe 'Pass-like command' Describe 'insert' It 'inserts a new multi-line entry' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 Data #|password #|Username: tester @@ -611,7 +611,7 @@ Describe 'Pass-like command' End It 'inserts a new single-line entry' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 Data #|pass-word #|pass-word @@ -632,7 +632,7 @@ Describe 'Pass-like command' End It 'inserts a new single-line entry with echo' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 Data "pass-word" When run script $1 insert -e newdir/newpass The output should include 'newdir/newpass' @@ -651,7 +651,7 @@ Describe 'Pass-like command' End It 'inserts an entry with local recipient list' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 Data "passWord" When run script $1 insert -e shared/newpass The output should include 'shared/newpass' @@ -673,7 +673,7 @@ Describe 'Pass-like command' End It 'inserts forcefully over an existing single-line entry with echo' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 Data "pass-word" When run script $1 insert -e -f subdir/file The output should include 'subdir/file' @@ -698,7 +698,7 @@ Describe 'Pass-like command' It 'creates a file using EDITOR' EDITOR='ed -c' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 Data #|a #|New password @@ -727,7 +727,7 @@ Describe 'Pass-like command' End It 'updates a file using EDITOR' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 Data #|2i #|New line @@ -756,7 +756,7 @@ Describe 'Pass-like command' End It 'reencrypts an updated file using EDITOR' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 Data #|a #|New option @@ -783,7 +783,7 @@ Describe 'Pass-like command' End It 'does not reencrypt an unchanged file using EDITOR' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 Data 'q' When run script $1 edit stale expected_file() { %text:expand @@ -798,7 +798,7 @@ Describe 'Pass-like command' End It 'allows cancelling file creation' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 Data 'q' When run script $1 edit subdir/new The status should be successful @@ -811,7 +811,7 @@ Describe 'Pass-like command' Describe 'generate' It 'generates a new file' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 generate newdir/newfile The output should include 'The generated password for' The file "${PREFIX}/newdir/newfile.$3" should be exist @@ -833,7 +833,7 @@ Describe 'Pass-like command' End It 'generates a new file without symbols' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 generate -n newfile 4 The output should include 'The generated password for' The file "${PREFIX}/newfile.$3" should be exist @@ -857,7 +857,7 @@ Describe 'Pass-like command' End It 'replaces an existing file when forced' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 generate -f fluff/three 20 The output should include 'The generated password for' The lines of contents of file "${PREFIX}/fluff/three.$3" should equal 3 @@ -875,7 +875,7 @@ Describe 'Pass-like command' End It 'replaces the first line of an existing file' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 generate -ni fluff/three 4 The output should include 'The generated password for' The lines of contents of file "${PREFIX}/fluff/three.$3" should equal 5 @@ -896,7 +896,7 @@ Describe 'Pass-like command' It 'pastes the generated password into the clipboard' DISPLAY=mock - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 generate -nc subdir/new The output should not include 'The generated password for' The output should not \ @@ -917,7 +917,7 @@ Describe 'Pass-like command' It 'displays the generated password as a QR-code' DISPLAY=mock - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 generate -qn new The output should not include 'The generated password for' The output should not include "$(@sed -n "2s/$3://p" "${PREFIX}/new.$3")" @@ -936,7 +936,7 @@ Describe 'Pass-like command' Describe 'rm' It 'removes a file without confirmation when forced' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 rm -f subdir/file The output should include 'subdir/file' The error should be blank @@ -953,7 +953,7 @@ Describe 'Pass-like command' End It 'does not remove a directory without `-r` even when forced' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 rm -f fluff The error should include 'fluff/' The error should include 's a directory' @@ -964,7 +964,7 @@ Describe 'Pass-like command' End It 'removes a directory when forced and recursive' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 rm -rf fluff/ The directory "${PREFIX}/fluff" should not be exist expected_log() { %text:expand @@ -988,7 +988,7 @@ Describe 'Pass-like command' Describe 'mv' It 'renames a file without reencrypting' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 mv subdir/file subdir/renamed The error should be blank The file "${PREFIX}/subdir/file.$3" should not be exist @@ -1015,7 +1015,7 @@ Describe 'Pass-like command' End It 'reencrypts a moved file' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 mv subdir/file shared/renamed The error should be blank The file "${PREFIX}/subdir/file.$3" should not be exist @@ -1043,7 +1043,7 @@ Describe 'Pass-like command' End It 'reencrypts relevant files in a moved directory' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 mv subdir shared/ The error should be blank The file "${PREFIX}/subdir/file.$3" should not be exist @@ -1080,7 +1080,7 @@ Describe 'Pass-like command' End It 'renames a directory with recipients' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 mv fluff filler The error should be blank The directory "${PREFIX}/fluff" should not be exist @@ -1109,7 +1109,7 @@ Describe 'Pass-like command' End It 'renames a directory without recipients' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 mv subdir newdir The error should be blank The directory "${PREFIX}/subdir" should not be exist @@ -1137,7 +1137,7 @@ Describe 'Pass-like command' End It 'overwrites an existing file when forced' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 mv -f fluff/two fluff/one The file "${PREFIX}/fluff/two.$3" should not be exist file_contents() { %text:expand @@ -1166,7 +1166,7 @@ Describe 'Pass-like command' End It 'does not merge directories recursively' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 mv -f subdir/ extra/ The error should include 'subdir' The error should include 'extra/' @@ -1179,7 +1179,7 @@ Describe 'Pass-like command' Describe 'cp' It 'copies a file without reencrypting' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 cp subdir/file subdir/copy The error should be blank file_contents() { %text:expand @@ -1205,7 +1205,7 @@ Describe 'Pass-like command' End It 'reencrypts a copied file' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 cp subdir/file shared/copy The error should be blank file_contents() { %text:expand @@ -1232,7 +1232,7 @@ Describe 'Pass-like command' End It 'reencrypts relevant files in a copied directory' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 cp subdir shared/ The error should be blank file_contents() { %text:expand @@ -1268,7 +1268,7 @@ Describe 'Pass-like command' End It 'copies a directory with recipients' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 cp fluff filler The error should be blank The directory "${PREFIX}/filler" should be exist @@ -1296,7 +1296,7 @@ Describe 'Pass-like command' End It 'copies a directory without recipients' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 cp subdir newdir The error should be blank file_contents() { %text:expand @@ -1323,7 +1323,7 @@ Describe 'Pass-like command' End It 'overwrites an existing file when forced' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 cp -f fluff/two fluff/one file_contents() { %text:expand #|${1}Recipient:master @@ -1350,7 +1350,7 @@ Describe 'Pass-like command' End It 'overwrites collisions when copying recursively and forcefully' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 cp -f subdir/ extra/ expected_log() { if [ "$2" = pashage ]; then @@ -1372,7 +1372,7 @@ Describe 'Pass-like command' Describe 'git' It 'transmits arguments to git' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 git log --format='%s' --stat The output should equal "$(setup_log)" End @@ -1381,7 +1381,7 @@ Describe 'Pass-like command' BeforeEach remove_git It 'fails without a git repository' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 git log The status should equal 1 The output should be blank @@ -1390,7 +1390,7 @@ Describe 'Pass-like command' End It 're-initializes the git repository' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 git init -b trunk The status should be successful The output should start with \ @@ -1403,7 +1403,7 @@ Describe 'Pass-like command' Describe 'help' It 'displays a help text with supported commands' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 help The output should include ' init ' The output should include ' find ' @@ -1420,7 +1420,7 @@ Describe 'Pass-like command' Describe 'version' It 'displays a version box' - Skip if 'pass needs bash' check_skip $1 + Skip if 'pass(age) needs bash' check_skip $2 When run script $1 version The output should include 'password manager' The output should start with '============='