3 # Try a set of credential helpers; the expected stdin,
4 # stdout and stderr should be provided on stdin,
8 read_chunk
>expect-stdout
&&
9 read_chunk
>expect-stderr
&&
10 test-credential
"$@" <stdin
>stdout
2>stderr
&&
11 test_cmp expect-stdout stdout
&&
12 if test_have_prereq MINGW
16 test_cmp expect-stderr stderr
28 # Clear any residual data from previous tests. We only
29 # need this when testing third-party helpers which read and
30 # write outside of our trash-directory sandbox.
32 # Don't bother checking for success here, as it is
33 # outside the scope of tests and represents a best effort to
34 # clean up after ourselves.
36 reject
$1 https example.com store-user
37 reject
$1 https example.com user1
38 reject
$1 https example.com user2
39 reject
$1 http path.tld user
40 reject
$1 https timeout.tld user
48 ) | test-credential reject
$1
54 test_expect_success
"helper ($HELPER) has no existing data" '
55 check fill $HELPER <<-\EOF
59 username=askpass-username
60 password=askpass-password
62 askpass: Username for '\''https://example.com'\'':
63 askpass: Password for '\''https://askpass-username@example.com'\'':
67 test_expect_success
"helper ($HELPER) stores password" '
68 check approve $HELPER <<-\EOF
76 test_expect_success
"helper ($HELPER) can retrieve password" '
77 check fill $HELPER <<-\EOF
87 test_expect_success
"helper ($HELPER) requires matching protocol" '
88 check fill $HELPER <<-\EOF
92 username=askpass-username
93 password=askpass-password
95 askpass: Username for '\''http://example.com'\'':
96 askpass: Password for '\''http://askpass-username@example.com'\'':
100 test_expect_success
"helper ($HELPER) requires matching host" '
101 check fill $HELPER <<-\EOF
105 username=askpass-username
106 password=askpass-password
108 askpass: Username for '\''https://other.tld'\'':
109 askpass: Password for '\''https://askpass-username@other.tld'\'':
113 test_expect_success
"helper ($HELPER) requires matching username" '
114 check fill $HELPER <<-\EOF
120 password=askpass-password
122 askpass: Password for '\''https://other@example.com'\'':
126 test_expect_success
"helper ($HELPER) requires matching path" '
127 test_config credential.usehttppath true &&
128 check approve $HELPER <<-\EOF &&
135 check fill $HELPER <<-\EOF
140 username=askpass-username
141 password=askpass-password
143 askpass: Username for '\''http://path.tld/bar.git'\'':
144 askpass: Password for '\''http://askpass-username@path.tld/bar.git'\'':
148 test_expect_success
"helper ($HELPER) can forget host" '
149 check reject $HELPER <<-\EOF &&
153 check fill $HELPER <<-\EOF
157 username=askpass-username
158 password=askpass-password
160 askpass: Username for '\''https://example.com'\'':
161 askpass: Password for '\''https://askpass-username@example.com'\'':
165 test_expect_success
"helper ($HELPER) can store multiple users" '
166 check approve $HELPER <<-\EOF &&
172 check approve $HELPER <<-\EOF &&
178 check fill $HELPER <<-\EOF &&
186 check fill $HELPER <<-\EOF
196 test_expect_success
"helper ($HELPER) can forget user" '
197 check reject $HELPER <<-\EOF &&
202 check fill $HELPER <<-\EOF
208 password=askpass-password
210 askpass: Password for '\''https://user1@example.com'\'':
214 test_expect_success
"helper ($HELPER) remembers other user" '
215 check fill $HELPER <<-\EOF
226 helper_test_timeout
() {
229 test_expect_success
"helper ($HELPER) times out" '
230 check approve "$HELPER" <<-\EOF &&
237 check fill "$HELPER" <<-\EOF
241 username=askpass-username
242 password=askpass-password
244 askpass: Username for '\''https://timeout.tld'\'':
245 askpass: Password for '\''https://askpass-username@timeout.tld'\'':
253 what
=`echo $1 | cut -d" " -f1 | tr A-Z a-z | tr -cd a-z`
257 GIT_ASKPASS
="$PWD/askpass"