3 # Try a set of credential helpers; the expected stdin,
4 # stdout and stderr should be provided on stdin,
11 credential_opts
="$credential_opts -c credential.helper='$arg'"
14 read_chunk
>expect-stdout
&&
15 read_chunk
>expect-stderr
&&
16 if ! eval "git $credential_opts credential $credential_cmd <stdin >stdout 2>stderr"; then
17 echo "git credential failed with code $?" &&
21 if test_have_prereq MINGW
25 test_cmp expect-stdout stdout
&&
26 if test_have_prereq MINGW
30 test_cmp expect-stderr stderr
42 # Clear any residual data from previous tests. We only
43 # need this when testing third-party helpers which read and
44 # write outside of our trash-directory sandbox.
46 # Don't bother checking for success here, as it is
47 # outside the scope of tests and represents a best effort to
48 # clean up after ourselves.
50 reject
$1 https example.com store-user
51 reject
$1 https example.com user1
52 reject
$1 https example.com user2
53 reject
$1 http path.tld user
54 reject
$1 https timeout.tld user
62 ) | git
-c credential.helper
=$1 credential reject
68 test_expect_success
"helper ($HELPER) has no existing data" '
69 check fill $HELPER <<-\EOF
75 username=askpass-username
76 password=askpass-password
78 askpass: Username for '\''https://example.com'\'':
79 askpass: Password for '\''https://askpass-username@example.com'\'':
83 test_expect_success
"helper ($HELPER) stores password" '
84 check approve $HELPER <<-\EOF
92 test_expect_success
"helper ($HELPER) can retrieve password" '
93 check fill $HELPER <<-\EOF
105 test_expect_success
"helper ($HELPER) requires matching protocol" '
106 check fill $HELPER <<-\EOF
112 username=askpass-username
113 password=askpass-password
115 askpass: Username for '\''http://example.com'\'':
116 askpass: Password for '\''http://askpass-username@example.com'\'':
120 test_expect_success
"helper ($HELPER) requires matching host" '
121 check fill $HELPER <<-\EOF
127 username=askpass-username
128 password=askpass-password
130 askpass: Username for '\''https://other.tld'\'':
131 askpass: Password for '\''https://askpass-username@other.tld'\'':
135 test_expect_success
"helper ($HELPER) requires matching username" '
136 check fill $HELPER <<-\EOF
144 password=askpass-password
146 askpass: Password for '\''https://other@example.com'\'':
150 test_expect_success
"helper ($HELPER) requires matching path" '
151 test_config credential.usehttppath true &&
152 check approve $HELPER <<-\EOF &&
159 check fill $HELPER <<-\EOF
167 username=askpass-username
168 password=askpass-password
170 askpass: Username for '\''http://path.tld/bar.git'\'':
171 askpass: Password for '\''http://askpass-username@path.tld/bar.git'\'':
175 test_expect_success
"helper ($HELPER) can forget host" '
176 check reject $HELPER <<-\EOF &&
180 check fill $HELPER <<-\EOF
186 username=askpass-username
187 password=askpass-password
189 askpass: Username for '\''https://example.com'\'':
190 askpass: Password for '\''https://askpass-username@example.com'\'':
194 test_expect_success
"helper ($HELPER) can store multiple users" '
195 check approve $HELPER <<-\EOF &&
201 check approve $HELPER <<-\EOF &&
207 check fill $HELPER <<-\EOF &&
217 check fill $HELPER <<-\EOF
229 test_expect_success
"helper ($HELPER) can forget user" '
230 check reject $HELPER <<-\EOF &&
235 check fill $HELPER <<-\EOF
243 password=askpass-password
245 askpass: Password for '\''https://user1@example.com'\'':
249 test_expect_success
"helper ($HELPER) remembers other user" '
250 check fill $HELPER <<-\EOF
263 helper_test_timeout
() {
266 test_expect_success
"helper ($HELPER) times out" '
267 check approve "$HELPER" <<-\EOF &&
274 check fill "$HELPER" <<-\EOF
280 username=askpass-username
281 password=askpass-password
283 askpass: Username for '\''https://timeout.tld'\'':
284 askpass: Password for '\''https://askpass-username@timeout.tld'\'':
292 what
=`echo $1 | cut -d" " -f1 | tr A-Z a-z | tr -cd a-z`
296 GIT_ASKPASS
="$PWD/askpass"