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 test_cmp expect-stdout stdout &&
22 test_cmp expect-stderr stderr
34 # Clear any residual data from previous tests. We only
35 # need this when testing third-party helpers which read and
36 # write outside of our trash-directory sandbox.
38 # Don't bother checking for success here, as it is
39 # outside the scope of tests and represents a best effort to
40 # clean up after ourselves.
42 reject $1 https example.com store-user
43 reject $1 https example.com user1
44 reject $1 https example.com user2
45 reject $1 http path.tld user
46 reject $1 https timeout.tld user
54 ) | git -c credential.helper=$1 credential reject
60 test_expect_success "helper ($HELPER) has no existing data" '
61 check fill $HELPER <<-\EOF
65 username=askpass-username
66 password=askpass-password
68 askpass: Username for '\''https://example.com'\'':
69 askpass: Password for '\''https://askpass-username@example.com'\'':
73 test_expect_success "helper ($HELPER) stores password" '
74 check approve $HELPER <<-\EOF
82 test_expect_success "helper ($HELPER) can retrieve password" '
83 check fill $HELPER <<-\EOF
93 test_expect_success "helper ($HELPER) requires matching protocol" '
94 check fill $HELPER <<-\EOF
98 username=askpass-username
99 password=askpass-password
101 askpass: Username for '\''http://example.com'\'':
102 askpass: Password for '\''http://askpass-username@example.com'\'':
106 test_expect_success "helper ($HELPER) requires matching host" '
107 check fill $HELPER <<-\EOF
111 username=askpass-username
112 password=askpass-password
114 askpass: Username for '\''https://other.tld'\'':
115 askpass: Password for '\''https://askpass-username@other.tld'\'':
119 test_expect_success "helper ($HELPER) requires matching username" '
120 check fill $HELPER <<-\EOF
126 password=askpass-password
128 askpass: Password for '\''https://other@example.com'\'':
132 test_expect_success "helper ($HELPER) requires matching path" '
133 test_config credential.usehttppath true &&
134 check approve $HELPER <<-\EOF &&
141 check fill $HELPER <<-\EOF
146 username=askpass-username
147 password=askpass-password
149 askpass: Username for '\''http://path.tld/bar.git'\'':
150 askpass: Password for '\''http://askpass-username@path.tld/bar.git'\'':
154 test_expect_success "helper ($HELPER) can forget host" '
155 check reject $HELPER <<-\EOF &&
159 check fill $HELPER <<-\EOF
163 username=askpass-username
164 password=askpass-password
166 askpass: Username for '\''https://example.com'\'':
167 askpass: Password for '\''https://askpass-username@example.com'\'':
171 test_expect_success "helper ($HELPER) can store multiple users" '
172 check approve $HELPER <<-\EOF &&
178 check approve $HELPER <<-\EOF &&
184 check fill $HELPER <<-\EOF &&
192 check fill $HELPER <<-\EOF
202 test_expect_success "helper ($HELPER) can forget user" '
203 check reject $HELPER <<-\EOF &&
208 check fill $HELPER <<-\EOF
214 password=askpass-password
216 askpass: Password for '\''https://user1@example.com'\'':
220 test_expect_success "helper ($HELPER) remembers other user" '
221 check fill $HELPER <<-\EOF
232 helper_test_timeout() {
235 test_expect_success "helper ($HELPER) times out" '
236 check approve "$HELPER" <<-\EOF &&
243 check fill "$HELPER" <<-\EOF
247 username=askpass-username
248 password=askpass-password
250 askpass: Username for '\''https://timeout.tld'\'':
251 askpass: Password for '\''https://askpass-username@timeout.tld'\'':
259 what=`echo $1 | cut -d" " -f1 | tr A-Z a-z | tr -cd a-z`
263 GIT_ASKPASS="$PWD/askpass"