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
47 reject
$1 https sso.tld
55 ) | git
-c credential.helper
=$1 credential reject
61 test_expect_success
"helper ($HELPER) has no existing data" '
62 check fill $HELPER <<-\EOF
68 username=askpass-username
69 password=askpass-password
71 askpass: Username for '\''https://example.com'\'':
72 askpass: Password for '\''https://askpass-username@example.com'\'':
76 test_expect_success
"helper ($HELPER) stores password" '
77 check approve $HELPER <<-\EOF
85 test_expect_success
"helper ($HELPER) can retrieve password" '
86 check fill $HELPER <<-\EOF
98 test_expect_success
"helper ($HELPER) requires matching protocol" '
99 check fill $HELPER <<-\EOF
105 username=askpass-username
106 password=askpass-password
108 askpass: Username for '\''http://example.com'\'':
109 askpass: Password for '\''http://askpass-username@example.com'\'':
113 test_expect_success
"helper ($HELPER) requires matching host" '
114 check fill $HELPER <<-\EOF
120 username=askpass-username
121 password=askpass-password
123 askpass: Username for '\''https://other.tld'\'':
124 askpass: Password for '\''https://askpass-username@other.tld'\'':
128 test_expect_success
"helper ($HELPER) requires matching username" '
129 check fill $HELPER <<-\EOF
137 password=askpass-password
139 askpass: Password for '\''https://other@example.com'\'':
143 test_expect_success
"helper ($HELPER) requires matching path" '
144 test_config credential.usehttppath true &&
145 check approve $HELPER <<-\EOF &&
152 check fill $HELPER <<-\EOF
160 username=askpass-username
161 password=askpass-password
163 askpass: Username for '\''http://path.tld/bar.git'\'':
164 askpass: Password for '\''http://askpass-username@path.tld/bar.git'\'':
168 test_expect_success
"helper ($HELPER) can forget host" '
169 check reject $HELPER <<-\EOF &&
173 check fill $HELPER <<-\EOF
179 username=askpass-username
180 password=askpass-password
182 askpass: Username for '\''https://example.com'\'':
183 askpass: Password for '\''https://askpass-username@example.com'\'':
187 test_expect_success
"helper ($HELPER) can store multiple users" '
188 check approve $HELPER <<-\EOF &&
194 check approve $HELPER <<-\EOF &&
200 check fill $HELPER <<-\EOF &&
210 check fill $HELPER <<-\EOF
222 test_expect_success
"helper ($HELPER) can forget user" '
223 check reject $HELPER <<-\EOF &&
228 check fill $HELPER <<-\EOF
236 password=askpass-password
238 askpass: Password for '\''https://user1@example.com'\'':
242 test_expect_success
"helper ($HELPER) remembers other user" '
243 check fill $HELPER <<-\EOF
255 test_expect_success
"helper ($HELPER) can store empty username" '
256 check approve $HELPER <<-\EOF &&
262 check fill $HELPER <<-\EOF
274 helper_test_timeout
() {
277 test_expect_success
"helper ($HELPER) times out" '
278 check approve "$HELPER" <<-\EOF &&
285 check fill "$HELPER" <<-\EOF
291 username=askpass-username
292 password=askpass-password
294 askpass: Username for '\''https://timeout.tld'\'':
295 askpass: Password for '\''https://askpass-username@timeout.tld'\'':
303 what
=$
(echo $1 | cut
-d" " -f1 |
tr A-Z a-z |
tr -cd a-z
)
307 GIT_ASKPASS
="$PWD/askpass"