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 test_cmp expect-stderr stderr
38 # Clear any residual data from previous tests. We only
39 # need this when testing third-party helpers which read and
40 # write outside of our trash-directory sandbox.
42 # Don't bother checking for success here, as it is
43 # outside the scope of tests and represents a best effort to
44 # clean up after ourselves.
46 reject $1 https example.com store-user
47 reject $1 https example.com user1
48 reject $1 https example.com user2
49 reject $1 http path.tld user
50 reject $1 https timeout.tld user
58 ) | git -c credential.helper=$1 credential reject
64 test_expect_success "helper ($HELPER) has no existing data" '
65 check fill $HELPER <<-\EOF
71 username=askpass-username
72 password=askpass-password
74 askpass: Username for '\''https://example.com'\'':
75 askpass: Password for '\''https://askpass-username@example.com'\'':
79 test_expect_success "helper ($HELPER) stores password" '
80 check approve $HELPER <<-\EOF
88 test_expect_success "helper ($HELPER) can retrieve password" '
89 check fill $HELPER <<-\EOF
101 test_expect_success "helper ($HELPER) requires matching protocol" '
102 check fill $HELPER <<-\EOF
108 username=askpass-username
109 password=askpass-password
111 askpass: Username for '\''http://example.com'\'':
112 askpass: Password for '\''http://askpass-username@example.com'\'':
116 test_expect_success "helper ($HELPER) requires matching host" '
117 check fill $HELPER <<-\EOF
123 username=askpass-username
124 password=askpass-password
126 askpass: Username for '\''https://other.tld'\'':
127 askpass: Password for '\''https://askpass-username@other.tld'\'':
131 test_expect_success "helper ($HELPER) requires matching username" '
132 check fill $HELPER <<-\EOF
140 password=askpass-password
142 askpass: Password for '\''https://other@example.com'\'':
146 test_expect_success "helper ($HELPER) requires matching path" '
147 test_config credential.usehttppath true &&
148 check approve $HELPER <<-\EOF &&
155 check fill $HELPER <<-\EOF
163 username=askpass-username
164 password=askpass-password
166 askpass: Username for '\''http://path.tld/bar.git'\'':
167 askpass: Password for '\''http://askpass-username@path.tld/bar.git'\'':
171 test_expect_success "helper ($HELPER) can forget host" '
172 check reject $HELPER <<-\EOF &&
176 check fill $HELPER <<-\EOF
182 username=askpass-username
183 password=askpass-password
185 askpass: Username for '\''https://example.com'\'':
186 askpass: Password for '\''https://askpass-username@example.com'\'':
190 test_expect_success "helper ($HELPER) can store multiple users" '
191 check approve $HELPER <<-\EOF &&
197 check approve $HELPER <<-\EOF &&
203 check fill $HELPER <<-\EOF &&
213 check fill $HELPER <<-\EOF
225 test_expect_success "helper ($HELPER) can forget user" '
226 check reject $HELPER <<-\EOF &&
231 check fill $HELPER <<-\EOF
239 password=askpass-password
241 askpass: Password for '\''https://user1@example.com'\'':
245 test_expect_success "helper ($HELPER) remembers other user" '
246 check fill $HELPER <<-\EOF
259 helper_test_timeout() {
262 test_expect_success "helper ($HELPER) times out" '
263 check approve "$HELPER" <<-\EOF &&
270 check fill "$HELPER" <<-\EOF
276 username=askpass-username
277 password=askpass-password
279 askpass: Username for '\''https://timeout.tld'\'':
280 askpass: Password for '\''https://askpass-username@timeout.tld'\'':
288 what=`echo $1 | cut -d" " -f1 | tr A-Z a-z | tr -cd a-z`
292 GIT_ASKPASS="$PWD/askpass"