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 test_cmp expect-stderr stderr
24 # Clear any residual data from previous tests. We only
25 # need this when testing third-party helpers which read and
26 # write outside of our trash-directory sandbox.
28 # Don't bother checking for success here, as it is
29 # outside the scope of tests and represents a best effort to
30 # clean up after ourselves.
32 reject $1 https example.com store-user
33 reject $1 https example.com user1
34 reject $1 https example.com user2
35 reject $1 http path.tld user
36 reject $1 https timeout.tld user
44 ) | test-credential reject $1
50 test_expect_success "helper ($HELPER) has no existing data" '
51 check fill $HELPER <<-\EOF
55 username=askpass-username
56 password=askpass-password
58 askpass: Username for '\''https://example.com'\'':
59 askpass: Password for '\''https://askpass-username@example.com'\'':
63 test_expect_success "helper ($HELPER) stores password" '
64 check approve $HELPER <<-\EOF
72 test_expect_success "helper ($HELPER) can retrieve password" '
73 check fill $HELPER <<-\EOF
83 test_expect_success "helper ($HELPER) requires matching protocol" '
84 check fill $HELPER <<-\EOF
88 username=askpass-username
89 password=askpass-password
91 askpass: Username for '\''http://example.com'\'':
92 askpass: Password for '\''http://askpass-username@example.com'\'':
96 test_expect_success "helper ($HELPER) requires matching host" '
97 check fill $HELPER <<-\EOF
101 username=askpass-username
102 password=askpass-password
104 askpass: Username for '\''https://other.tld'\'':
105 askpass: Password for '\''https://askpass-username@other.tld'\'':
109 test_expect_success "helper ($HELPER) requires matching username" '
110 check fill $HELPER <<-\EOF
116 password=askpass-password
118 askpass: Password for '\''https://other@example.com'\'':
122 test_expect_success "helper ($HELPER) requires matching path" '
123 test_config credential.usehttppath true &&
124 check approve $HELPER <<-\EOF &&
131 check fill $HELPER <<-\EOF
136 username=askpass-username
137 password=askpass-password
139 askpass: Username for '\''http://path.tld/bar.git'\'':
140 askpass: Password for '\''http://askpass-username@path.tld/bar.git'\'':
144 test_expect_success "helper ($HELPER) can forget host" '
145 check reject $HELPER <<-\EOF &&
149 check fill $HELPER <<-\EOF
153 username=askpass-username
154 password=askpass-password
156 askpass: Username for '\''https://example.com'\'':
157 askpass: Password for '\''https://askpass-username@example.com'\'':
161 test_expect_success "helper ($HELPER) can store multiple users" '
162 check approve $HELPER <<-\EOF &&
168 check approve $HELPER <<-\EOF &&
174 check fill $HELPER <<-\EOF &&
182 check fill $HELPER <<-\EOF
192 test_expect_success "helper ($HELPER) can forget user" '
193 check reject $HELPER <<-\EOF &&
198 check fill $HELPER <<-\EOF
204 password=askpass-password
206 askpass: Password for '\''https://user1@example.com'\'':
210 test_expect_success "helper ($HELPER) remembers other user" '
211 check fill $HELPER <<-\EOF
222 helper_test_timeout() {
225 test_expect_success "helper ($HELPER) times out" '
226 check approve "$HELPER" <<-\EOF &&
233 check fill "$HELPER" <<-\EOF
237 username=askpass-username
238 password=askpass-password
240 askpass: Username for '\''https://timeout.tld'\'':
241 askpass: Password for '\''https://askpass-username@timeout.tld'\'':
249 what=`echo $1 | cut -d" " -f1 | tr A-Z a-z | tr -cd a-z`
253 GIT_ASKPASS="$PWD/askpass"