Skip to content

Commit 861444f

Browse files
peffgitster
authored andcommitted
t: add test harness for external credential helpers
We already have tests for the internal helpers, but it's nice to give authors of external tools an easy way to sanity-check their helpers. If you have written the "git-credential-foo" helper, you can do so with: GIT_TEST_CREDENTIAL_HELPER=foo \ make t0303-credential-external.sh This assumes that your helper is capable of both storing and retrieving credentials (some helpers may be read-only, and they will fail these tests). If your helper supports time-based expiration with a configurable timeout, you can test that feature like this: GIT_TEST_CREDENTIAL_HELPER_TIMEOUT="foo --timeout=1" \ make t0303-credential-external.sh Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 71e1b4b commit 861444f

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

t/t0303-credential-external.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/sh
2+
3+
test_description='external credential helper tests'
4+
. ./test-lib.sh
5+
. "$TEST_DIRECTORY"/lib-credential.sh
6+
7+
pre_test() {
8+
test -z "$GIT_TEST_CREDENTIAL_HELPER_SETUP" ||
9+
eval "$GIT_TEST_CREDENTIAL_HELPER_SETUP"
10+
11+
# clean before the test in case there is cruft left
12+
# over from a previous run that would impact results
13+
helper_test_clean "$GIT_TEST_CREDENTIAL_HELPER"
14+
}
15+
16+
post_test() {
17+
# clean afterwards so that we are good citizens
18+
# and don't leave cruft in the helper's storage, which
19+
# might be long-term system storage
20+
helper_test_clean "$GIT_TEST_CREDENTIAL_HELPER"
21+
}
22+
23+
if test -z "$GIT_TEST_CREDENTIAL_HELPER"; then
24+
say "# skipping external helper tests (set GIT_TEST_CREDENTIAL_HELPER)"
25+
else
26+
pre_test
27+
helper_test "$GIT_TEST_CREDENTIAL_HELPER"
28+
post_test
29+
fi
30+
31+
if test -z "$GIT_TEST_CREDENTIAL_HELPER_TIMEOUT"; then
32+
say "# skipping external helper timeout tests"
33+
else
34+
pre_test
35+
helper_test_timeout "$GIT_TEST_CREDENTIAL_HELPER_TIMEOUT"
36+
post_test
37+
fi
38+
39+
test_done

0 commit comments

Comments
 (0)