• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

sschmid / pw-terminal-password-manager / 20757180796

06 Jan 2026 05:57PM UTC coverage: 87.234% (+0.1%) from 87.123%
20757180796

push

github

sschmid
Prompt password until retyped password matches

1 of 8 new or added lines in 1 file covered. (12.5%)

18 existing lines in 2 files now uncovered.

451 of 517 relevant lines covered (87.23%)

403.33 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.2
/test/test-helper.bash
1
# shellcheck disable=SC2034
2
_common_setup() {
3
        load 'test_helper/bats-support/load.bash'
978✔
4
        load 'test_helper/bats-assert/load.bash'
976✔
5
        load 'test_helper/bats-file/load.bash'
980✔
6

7
        export XDG_CONFIG_HOME="${BATS_TEST_TMPDIR}/.config"
1,452✔
8
        PW_CONFIG="${XDG_CONFIG_HOME}/pw/pw.conf"
968✔
9
        mkdir -p "${XDG_CONFIG_HOME}/pw"
968✔
10

11
        PROJECT_ROOT="$(cd "${BATS_TEST_DIRNAME}/.." &>/dev/null && pwd)"
2,904✔
12
        PATH="${PROJECT_ROOT}/src:${PATH}"
972✔
13

14
        KEYCHAIN_TEST_PASSWORD=" test password "
972✔
15
        NAME_A=" a test name "
974✔
16
        NAME_B=" b test name "
976✔
17
        ACCOUNT_A=" a test account "
976✔
18
        ACCOUNT_B=" b test account "
976✔
19
        URL_A=" a test url "
972✔
20
        URL_B=" b test url "
974✔
21
        SINGLE_LINE_NOTES=" a single line note "
976✔
22
        MULTI_LINE_NOTES=" a test note
23
with multiple lines
24
and spaces "
976✔
25
        PW_1=" 1 test pw "
974✔
26
        PW_2=" 2 test pw "
972✔
27
        PW_3=" 3 test pw "
972✔
28
}
29

30
_set_config_with_copy_paste() {
31
        cat > "${PW_CONFIG}" << 'EOF'
632✔
32
[general]
33
copy = cat > "${BATS_TEST_TMPDIR}/test_clipboard"
34
paste = cat "${BATS_TEST_TMPDIR}/test_clipboard"
35
EOF
36
}
37

38
_copy() {
39
        cat > "${BATS_TEST_TMPDIR}/test_clipboard"
12✔
40
}
41

42
_paste() {
43
        cat "${BATS_TEST_TMPDIR}/test_clipboard"
26✔
44
}
45

46
_config_append_with_plugin() {
47
        cat >> "${PW_CONFIG}" << EOF
620✔
48
[plugins]
49
# unknown key
50
pluginX = invalid
51
plugin = $1
52
EOF
53
}
54

55
_config_append_with_test_plugins() {
56
        cat >> "${1:-"${PW_CONFIG}"}" << EOF
288✔
57
[plugins]
58
# unknown key
59
pluginX = invalid
60
plugin = ${BATS_TEST_DIRNAME}/fixtures/plugins/collision
61
plugin = ${BATS_TEST_DIRNAME}/fixtures/plugins/test
62
EOF
63
}
64

65
_config_append_keychains() {
66
        echo "[keychains]" >> "${PW_CONFIG}"
56✔
67
        printf "keychain = %s\n" "$@" >> "${PW_CONFIG}"
56✔
68
}
69

70
_config_append_keychains_with_key() {
71
        echo "[keychains]" >> "${PW_CONFIG}"
24✔
72
        printf "%s\n" "$@" >> "${PW_CONFIG}"
24✔
73
}
74

75
assert_init_already_exists() {
76
        run pw init "${PW_KEYCHAIN}"
12✔
77
        assert_failure
12✔
78
        assert_output "pw: ${PW_KEYCHAIN} already exists."
12✔
79
}
80

81
assert_item_exists() {
82
        local password="$1"; shift
712✔
83
        run pw -p "$@"
356✔
84
        assert_success
364✔
85
        assert_output "${password}"
364✔
86
}
87

88
assert_item_not_exists() {
89
        run pw "$@"
60✔
90
        assert_failure
32✔
91
        assert_item_not_exists_output "$@"
32✔
92
}
93

94
assert_adds_item() {
95
        local password="$1"; shift
648✔
96
        run pw add "$@" <<< "${password}"
324✔
97
        assert_success
320✔
98
        refute_output
320✔
99
}
100

101
assert_adds_item_with_keychain_password() {
102
        local password="$1"; shift
336✔
103
        run pw add "$@" << EOF
168✔
104
${KEYCHAIN_TEST_PASSWORD}
105
${password}
106
EOF
107
        assert_success
156✔
108
        refute_output
156✔
109
}
110

111
assert_item_already_exists() {
112
        local password="$1"; shift
24✔
113
        run pw add "$@" <<< "${password}"
12✔
114
        assert_failure
12✔
115
        assert_item_already_exists_output "$@"
12✔
116
}
117

118
assert_item_already_exists_with_keychain_password() {
119
        local password="$1"; shift
8✔
120
        run pw add "$@" << EOF
4✔
121
${KEYCHAIN_TEST_PASSWORD}
122
${password}
123
EOF
124
        assert_failure
×
125
        assert_item_already_exists_output "$@"
×
126
}
127

128
assert_removes_item() {
129
        run pw rm "$@"
28✔
130
        assert_success
32✔
131
        assert_removes_item_output "$@"
32✔
132
}
133

134
assert_rm_not_found() {
135
        run pw rm "$@"
20✔
136
        assert_failure
16✔
137
        assert_rm_not_found_output "$@"
16✔
138
}
139

140
assert_edits_item() {
141
        local password="$1"; shift
80✔
142
        run pw edit "$@" <<< "${password}"
40✔
143
        assert_success
40✔
144
        refute_output
40✔
145
}
146

147
assert_edits_item_with_keychain_password() {
148
        local password="$1"; shift
48✔
149
        run pw edit "$@" << EOF
24✔
150
${KEYCHAIN_TEST_PASSWORD}
151
${password}
152
EOF
153
        assert_success
20✔
154
        refute_output
20✔
155
}
156

157
assert_renames_item() {
158
        local rename="$1"; shift
24✔
159
        run pw mv "$@" <<< "${rename}"
12✔
160
        assert_success
16✔
161
        refute_output
16✔
162
}
163

164
assert_renames_item_with_keychain_password() {
165
        local rename="$1"; shift
56✔
166
        run pw mv "$@" << EOF
28✔
167
${KEYCHAIN_TEST_PASSWORD}
168
${rename}
169
EOF
170
        assert_success
32✔
171
}
172

173
_skip_manual_test() {
174
        if [[ -v PW_TEST_RUN_MANUAL_TESTS ]]; then
76✔
UNCOV
175
                echo "# Please enter $1" >&3
×
176
        else
177
                skip "Requires user input. Use test/run -m to also run manual tests."
76✔
178
        fi
179
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc