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
67 username=askpass-username
68 password=askpass-password
70 askpass: Username for '\''https://example.com'\'':
71 askpass: Password for '\''https://askpass-username@example.com'\'':
75 test_expect_success "helper ($HELPER) stores password" '
76 check approve $HELPER <<-\EOF
84 test_expect_success "helper ($HELPER) can retrieve password" '
85 check fill $HELPER <<-\EOF
97 test_expect_success "helper ($HELPER) requires matching protocol" '
98 check fill $HELPER <<-\EOF
104 username=askpass-username
105 password=askpass-password
107 askpass: Username for '\''http://example.com'\'':
108 askpass: Password for '\''http://askpass-username@example.com'\'':
112 test_expect_success "helper ($HELPER) requires matching host" '
113 check fill $HELPER <<-\EOF
119 username=askpass-username
120 password=askpass-password
122 askpass: Username for '\''https://other.tld'\'':
123 askpass: Password for '\''https://askpass-username@other.tld'\'':
127 test_expect_success "helper ($HELPER) requires matching username" '
128 check fill $HELPER <<-\EOF
136 password=askpass-password
138 askpass: Password for '\''https://other@example.com'\'':
142 test_expect_success "helper ($HELPER) requires matching path" '
143 test_config credential.usehttppath true &&
144 check approve $HELPER <<-\EOF &&
151 check fill $HELPER <<-\EOF
159 username=askpass-username
160 password=askpass-password
162 askpass: Username for '\''http://path.tld/bar.git'\'':
163 askpass: Password for '\''http://askpass-username@path.tld/bar.git'\'':
167 test_expect_success "helper ($HELPER) can forget host" '
168 check reject $HELPER <<-\EOF &&
172 check fill $HELPER <<-\EOF
178 username=askpass-username
179 password=askpass-password
181 askpass: Username for '\''https://example.com'\'':
182 askpass: Password for '\''https://askpass-username@example.com'\'':
186 test_expect_success "helper ($HELPER) can store multiple users" '
187 check approve $HELPER <<-\EOF &&
193 check approve $HELPER <<-\EOF &&
199 check fill $HELPER <<-\EOF &&
209 check fill $HELPER <<-\EOF
221 test_expect_success "helper ($HELPER) can forget user" '
222 check reject $HELPER <<-\EOF &&
227 check fill $HELPER <<-\EOF
235 password=askpass-password
237 askpass: Password for '\''https://user1@example.com'\'':
241 test_expect_success "helper ($HELPER) remembers other user" '
242 check fill $HELPER <<-\EOF
255 helper_test_timeout() {
258 test_expect_success "helper ($HELPER) times out" '
259 check approve "$HELPER" <<-\EOF &&
266 check fill "$HELPER" <<-\EOF
272 username=askpass-username
273 password=askpass-password
275 askpass: Username for '\''https://timeout.tld'\'':
276 askpass: Password for '\''https://askpass-username@timeout.tld'\'':
284 what=$(echo $1 | cut -d" " -f1 | tr A-Z a-z | tr -cd a-z)
288 GIT_ASKPASS="$PWD/askpass"