introduce credentials API
[git/jrn.git] / t / lib-credential.sh
blob54ae1f484ce6a70efaea7ec567d4115f43de3e02
1 #!/bin/sh
3 # Try a set of credential helpers; the expected stdin,
4 # stdout and stderr should be provided on stdin,
5 # separated by "--".
6 check() {
7 read_chunk >stdin &&
8 read_chunk >expect-stdout &&
9 read_chunk >expect-stderr &&
10 test-credential "$@" <stdin >stdout 2>stderr &&
11 test_cmp expect-stdout stdout &&
12 test_cmp expect-stderr stderr
15 read_chunk() {
16 while read line; do
17 case "$line" in
18 --) break ;;
19 *) echo "$line" ;;
20 esac
21 done
25 cat >askpass <<\EOF
26 #!/bin/sh
27 echo >&2 askpass: $*
28 what=`echo $1 | cut -d" " -f1 | tr A-Z a-z | tr -cd a-z`
29 echo "askpass-$what"
30 EOF
31 chmod +x askpass
32 GIT_ASKPASS="$PWD/askpass"
33 export GIT_ASKPASS