@@ -40,43 +40,71 @@ test_expect_success 'setup helper scripts' '
40
40
41
41
test_expect_success ' credential_fill invokes helper' '
42
42
check fill "verbatim foo bar" <<-\EOF
43
+ protocol=http
44
+ host=example.com
43
45
--
46
+ protocol=http
47
+ host=example.com
44
48
username=foo
45
49
password=bar
46
50
--
47
51
verbatim: get
52
+ verbatim: protocol=http
53
+ verbatim: host=example.com
48
54
EOF
49
55
'
50
56
51
57
test_expect_success ' credential_fill invokes multiple helpers' '
52
58
check fill useless "verbatim foo bar" <<-\EOF
59
+ protocol=http
60
+ host=example.com
53
61
--
62
+ protocol=http
63
+ host=example.com
54
64
username=foo
55
65
password=bar
56
66
--
57
67
useless: get
68
+ useless: protocol=http
69
+ useless: host=example.com
58
70
verbatim: get
71
+ verbatim: protocol=http
72
+ verbatim: host=example.com
59
73
EOF
60
74
'
61
75
62
76
test_expect_success ' credential_fill stops when we get a full response' '
63
77
check fill "verbatim one two" "verbatim three four" <<-\EOF
78
+ protocol=http
79
+ host=example.com
64
80
--
81
+ protocol=http
82
+ host=example.com
65
83
username=one
66
84
password=two
67
85
--
68
86
verbatim: get
87
+ verbatim: protocol=http
88
+ verbatim: host=example.com
69
89
EOF
70
90
'
71
91
72
92
test_expect_success ' credential_fill continues through partial response' '
73
93
check fill "verbatim one \"\"" "verbatim two three" <<-\EOF
94
+ protocol=http
95
+ host=example.com
74
96
--
97
+ protocol=http
98
+ host=example.com
75
99
username=two
76
100
password=three
77
101
--
78
102
verbatim: get
103
+ verbatim: protocol=http
104
+ verbatim: host=example.com
79
105
verbatim: get
106
+ verbatim: protocol=http
107
+ verbatim: host=example.com
80
108
verbatim: username=one
81
109
EOF
82
110
'
@@ -102,21 +130,29 @@ test_expect_success 'credential_fill passes along metadata' '
102
130
103
131
test_expect_success ' credential_approve calls all helpers' '
104
132
check approve useless "verbatim one two" <<-\EOF
133
+ protocol=http
134
+ host=example.com
105
135
username=foo
106
136
password=bar
107
137
--
108
138
--
109
139
useless: store
140
+ useless: protocol=http
141
+ useless: host=example.com
110
142
useless: username=foo
111
143
useless: password=bar
112
144
verbatim: store
145
+ verbatim: protocol=http
146
+ verbatim: host=example.com
113
147
verbatim: username=foo
114
148
verbatim: password=bar
115
149
EOF
116
150
'
117
151
118
152
test_expect_success ' do not bother storing password-less credential' '
119
153
check approve useless <<-\EOF
154
+ protocol=http
155
+ host=example.com
120
156
username=foo
121
157
--
122
158
--
@@ -126,48 +162,70 @@ test_expect_success 'do not bother storing password-less credential' '
126
162
127
163
test_expect_success ' credential_reject calls all helpers' '
128
164
check reject useless "verbatim one two" <<-\EOF
165
+ protocol=http
166
+ host=example.com
129
167
username=foo
130
168
password=bar
131
169
--
132
170
--
133
171
useless: erase
172
+ useless: protocol=http
173
+ useless: host=example.com
134
174
useless: username=foo
135
175
useless: password=bar
136
176
verbatim: erase
177
+ verbatim: protocol=http
178
+ verbatim: host=example.com
137
179
verbatim: username=foo
138
180
verbatim: password=bar
139
181
EOF
140
182
'
141
183
142
184
test_expect_success ' usernames can be preserved' '
143
185
check fill "verbatim \"\" three" <<-\EOF
186
+ protocol=http
187
+ host=example.com
144
188
username=one
145
189
--
190
+ protocol=http
191
+ host=example.com
146
192
username=one
147
193
password=three
148
194
--
149
195
verbatim: get
196
+ verbatim: protocol=http
197
+ verbatim: host=example.com
150
198
verbatim: username=one
151
199
EOF
152
200
'
153
201
154
202
test_expect_success ' usernames can be overridden' '
155
203
check fill "verbatim two three" <<-\EOF
204
+ protocol=http
205
+ host=example.com
156
206
username=one
157
207
--
208
+ protocol=http
209
+ host=example.com
158
210
username=two
159
211
password=three
160
212
--
161
213
verbatim: get
214
+ verbatim: protocol=http
215
+ verbatim: host=example.com
162
216
verbatim: username=one
163
217
EOF
164
218
'
165
219
166
220
test_expect_success ' do not bother completing already-full credential' '
167
221
check fill "verbatim three four" <<-\EOF
222
+ protocol=http
223
+ host=example.com
168
224
username=one
169
225
password=two
170
226
--
227
+ protocol=http
228
+ host=example.com
171
229
username=one
172
230
password=two
173
231
--
@@ -179,23 +237,31 @@ test_expect_success 'do not bother completing already-full credential' '
179
237
# askpass helper is run, we know the internal getpass is working.
180
238
test_expect_success ' empty helper list falls back to internal getpass' '
181
239
check fill <<-\EOF
240
+ protocol=http
241
+ host=example.com
182
242
--
243
+ protocol=http
244
+ host=example.com
183
245
username=askpass-username
184
246
password=askpass-password
185
247
--
186
- askpass: Username:
187
- askpass: Password:
248
+ askpass: Username for ' \' ' http://example.com ' \' ' :
249
+ askpass: Password for ' \' ' http://[email protected] ' \' ' :
188
250
EOF
189
251
'
190
252
191
253
test_expect_success ' internal getpass does not ask for known username' '
192
254
check fill <<-\EOF
255
+ protocol=http
256
+ host=example.com
193
257
username=foo
194
258
--
259
+ protocol=http
260
+ host=example.com
195
261
username=foo
196
262
password=askpass-password
197
263
--
198
- askpass: Password:
264
+ askpass: Password for ' \' ' http://[email protected] ' \' ' :
199
265
EOF
200
266
'
201
267
@@ -207,7 +273,11 @@ HELPER="!f() {
207
273
test_expect_success ' respect configured credentials' '
208
274
test_config credential.helper "$HELPER" &&
209
275
check fill <<-\EOF
276
+ protocol=http
277
+ host=example.com
210
278
--
279
+ protocol=http
280
+ host=example.com
211
281
username=foo
212
282
password=bar
213
283
--
@@ -298,11 +368,16 @@ test_expect_success 'helpers can abort the process' '
298
368
test_must_fail git \
299
369
-c credential.helper=quit \
300
370
-c credential.helper="verbatim foo bar" \
301
- credential fill >stdout 2>stderr &&
371
+ credential fill >stdout 2>stderr <<-\EOF &&
372
+ protocol=http
373
+ host=example.com
374
+ EOF
302
375
>expect &&
303
376
test_cmp expect stdout &&
304
377
cat >expect <<-\EOF &&
305
378
quit: get
379
+ quit: protocol=http
380
+ quit: host=example.com
306
381
fatal: credential helper ' \' ' quit' \' ' told us to quit
307
382
EOF
308
383
test_i18ncmp expect stderr
@@ -311,11 +386,17 @@ test_expect_success 'helpers can abort the process' '
311
386
test_expect_success ' empty helper spec resets helper list' '
312
387
test_config credential.helper "verbatim file file" &&
313
388
check fill "" "verbatim cmdline cmdline" <<-\EOF
389
+ protocol=http
390
+ host=example.com
314
391
--
392
+ protocol=http
393
+ host=example.com
315
394
username=cmdline
316
395
password=cmdline
317
396
--
318
397
verbatim: get
398
+ verbatim: protocol=http
399
+ verbatim: host=example.com
319
400
EOF
320
401
'
321
402
0 commit comments