240
EOF
241
'
242
243
+test_expect_success 'match multiple configured helpers' '
244
+ test_config credential.helper "verbatim \"\" \"\"" &&
245
+ test_config credential.https://example.com.helper "$HELPER" &&
246
+ check fill <<-\EOF
247
+ protocol=https
248
+ host=example.com
249
+ path=repo.git
250
+ --
251
+ protocol=https
252
+ host=example.com
253
+ username=foo
254
+ password=bar
255
+ --
256
+ verbatim: get
257
+ verbatim: protocol=https
258
+ verbatim: host=example.com
259
+ EOF
260
+'
261
+
262
+test_expect_success 'match multiple configured helpers with URLs' '
263
+ test_config credential.https://example.com/repo.git.helper "verbatim \"\" \"\"" &&
264
+ test_config credential.https://example.com.helper "$HELPER" &&
265
+ check fill <<-\EOF
266
+ protocol=https
267
+ host=example.com
268
+ path=repo.git
269
+ --
270
+ protocol=https
271
+ host=example.com
272
+ username=foo
273
+ password=bar
274
+ --
275
+ verbatim: get
276
+ verbatim: protocol=https
277
+ verbatim: host=example.com
278
+ EOF
279
+'
280
+
281
+test_expect_success 'match percent-encoded values' '
282
+ test_config credential.https://example.com/%2566.git.helper "$HELPER" &&
283
+ check fill <<-\EOF
284
+ url=https://example.com/%2566.git
285
+ --
286
+ protocol=https
287
+ host=example.com
288
+ username=foo
289
+ password=bar
290
+ --
291
+ EOF
292
+'
293
+
294
test_expect_success 'pull username from config' '
295
test_config credential.https://example.com.username foo &&
296
check fill <<-\EOF
306
EOF
307
'
308
309
+test_expect_success 'honors username from URL over helper (URL)' '
310
+ test_config credential.https://example.com.username bob &&
311
+ test_config credential.https://example.com.helper "verbatim \"\" bar" &&
312
+ check fill <<-\EOF
313
+ url=https://alice@example.com
314
+ --
315
+ protocol=https
316
+ host=example.com
317
+ username=alice
318
+ password=bar
319
+ --
320
+ verbatim: get
321
+ verbatim: protocol=https
322
+ verbatim: host=example.com
323
+ verbatim: username=alice
324
+ EOF
325
+'
326
+
327
+test_expect_success 'honors username from URL over helper (components)' '
328
+ test_config credential.https://example.com.username bob &&
329
+ test_config credential.https://example.com.helper "verbatim \"\" bar" &&
330
+ check fill <<-\EOF
331
+ protocol=https
332
+ host=example.com
333
+ username=alice
334
+ --
335
+ protocol=https
336
+ host=example.com
337
+ username=alice
338
+ password=bar
339
+ --
340
+ verbatim: get
341
+ verbatim: protocol=https
342
+ verbatim: host=example.com
343
+ verbatim: username=alice
344
+ EOF
345
+'
346
+
347
+test_expect_failure 'last matching username wins' '
348
+ test_config credential.https://example.com/path.git.username bob &&
349
+ test_config credential.https://example.com.username alice &&
350
+ test_config credential.https://example.com.helper "verbatim \"\" bar" &&
351
+ check fill <<-\EOF
352
+ url=https://example.com/path.git
353
+ --
354
+ protocol=https
355
+ host=example.com
356
+ username=alice
357
+ password=bar
358
+ --
359
+ verbatim: get
360
+ verbatim: protocol=https
361
+ verbatim: host=example.com
362
+ verbatim: username=alice
363
+ EOF
364
+'
365
+
366
test_expect_success 'http paths can be part of context' '
367
check fill "verbatim foo bar" <<-\EOF &&
368
protocol=https