74
git ls-remote "$HTTPD_URL/custom_auth/repo.git" &&
75
76
expect_credential_query get <<-EOF &&
77
+ capability[]=authtype
78
protocol=http
79
host=$HTTPD_DEST
80
wwwauth[]=Basic realm="example.com"
88
EOF
89
'
90
91
+test_expect_success 'access using basic auth via authtype' '
92
+ test_when_finished "per_test_cleanup" &&
93
+
94
+ set_credential_reply get <<-EOF &&
95
+ capability[]=authtype
96
+ authtype=Basic
97
+ credential=YWxpY2U6c2VjcmV0LXBhc3N3ZA==
98
+ EOF
99
+
100
+ # Basic base64(alice:secret-passwd)
101
+ cat >"$HTTPD_ROOT_PATH/custom-auth.valid" <<-EOF &&
102
+ Basic YWxpY2U6c2VjcmV0LXBhc3N3ZA==
103
+ EOF
104
+
105
+ cat >"$HTTPD_ROOT_PATH/custom-auth.challenge" <<-EOF &&
106
+ WWW-Authenticate: Basic realm="example.com"
107
+ EOF
108
+
109
+ test_config_global credential.helper test-helper &&
110
+ GIT_CURL_VERBOSE=1 git ls-remote "$HTTPD_URL/custom_auth/repo.git" &&
111
+
112
+ expect_credential_query get <<-EOF &&
113
+ capability[]=authtype
114
+ protocol=http
115
+ host=$HTTPD_DEST
116
+ wwwauth[]=Basic realm="example.com"
117
+ EOF
118
+
119
+ expect_credential_query store <<-EOF
120
+ capability[]=authtype
121
+ authtype=Basic
122
+ credential=YWxpY2U6c2VjcmV0LXBhc3N3ZA==
123
+ protocol=http
124
+ host=$HTTPD_DEST
125
+ EOF
126
+'
127
+
128
test_expect_success 'access using basic auth invalid credentials' '
129
test_when_finished "per_test_cleanup" &&
130
146
test_must_fail git ls-remote "$HTTPD_URL/custom_auth/repo.git" &&
147
148
expect_credential_query get <<-EOF &&
149
+ capability[]=authtype
150
protocol=http
151
host=$HTTPD_DEST
152
wwwauth[]=Basic realm="example.com"
184
git ls-remote "$HTTPD_URL/custom_auth/repo.git" &&
185
186
expect_credential_query get <<-EOF &&
187
+ capability[]=authtype
188
protocol=http
189
host=$HTTPD_DEST
190
wwwauth[]=FooBar param1="value1" param2="value2"
223
git ls-remote "$HTTPD_URL/custom_auth/repo.git" &&
224
225
expect_credential_query get <<-EOF &&
226
+ capability[]=authtype
227
protocol=http
228
host=$HTTPD_DEST
229
wwwauth[]=foobar param1="value1" param2="value2"
267
git ls-remote "$HTTPD_URL/custom_auth/repo.git" &&
268
269
expect_credential_query get <<-EOF &&
270
+ capability[]=authtype
271
protocol=http
272
host=$HTTPD_DEST
273
wwwauth[]=FooBar param1="value1" param2="value2"
313
git ls-remote "$HTTPD_URL/custom_auth/repo.git" &&
314
315
expect_credential_query get <<-EOF &&
316
+ capability[]=authtype
317
protocol=http
318
host=$HTTPD_DEST
319
wwwauth[]=FooBar param1="value1" param2="value2"
355
git ls-remote "$HTTPD_URL/custom_auth/repo.git" &&
356
357
expect_credential_query get <<-EOF &&
358
+ capability[]=authtype
359
protocol=http
360
host=$HTTPD_DEST
361
wwwauth[]=FooBar param1="value1" param2="value2"
370
EOF
371
'
372
373
+test_expect_success 'access using bearer auth' '
374
+ test_when_finished "per_test_cleanup" &&
375
+
376
+ set_credential_reply get <<-EOF &&
377
+ capability[]=authtype
378
+ authtype=Bearer
379
+ credential=YS1naXQtdG9rZW4=
380
+ EOF
381
+
382
+ # Basic base64(a-git-token)
383
+ cat >"$HTTPD_ROOT_PATH/custom-auth.valid" <<-EOF &&
384
+ Bearer YS1naXQtdG9rZW4=
385
+ EOF
386
+
387
+ CHALLENGE="$HTTPD_ROOT_PATH/custom-auth.challenge" &&
388
+
389
+ cat >"$HTTPD_ROOT_PATH/custom-auth.challenge" <<-EOF &&
390
+ WWW-Authenticate: FooBar param1="value1" param2="value2"
391
+ WWW-Authenticate: Bearer authorize_uri="id.example.com" p=1 q=0
392
+ WWW-Authenticate: Basic realm="example.com"
393
+ EOF
394
+
395
+ test_config_global credential.helper test-helper &&
396
+ git ls-remote "$HTTPD_URL/custom_auth/repo.git" &&
397
+
398
+ expect_credential_query get <<-EOF &&
399
+ capability[]=authtype
400
+ protocol=http
401
+ host=$HTTPD_DEST
402
+ wwwauth[]=FooBar param1="value1" param2="value2"
403
+ wwwauth[]=Bearer authorize_uri="id.example.com" p=1 q=0
404
+ wwwauth[]=Basic realm="example.com"
405
+ EOF
406
+
407
+ expect_credential_query store <<-EOF
408
+ capability[]=authtype
409
+ authtype=Bearer
410
+ credential=YS1naXQtdG9rZW4=
411
+ protocol=http
412
+ host=$HTTPD_DEST
413
+ EOF
414
+'
415
+
416
+test_expect_success 'access using bearer auth with invalid credentials' '
417
+ test_when_finished "per_test_cleanup" &&
418
+
419
+ set_credential_reply get <<-EOF &&
420
+ capability[]=authtype
421
+ authtype=Bearer
422
+ credential=incorrect-token
423
+ EOF
424
+
425
+ # Basic base64(a-git-token)
426
+ cat >"$HTTPD_ROOT_PATH/custom-auth.valid" <<-EOF &&
427
+ Bearer YS1naXQtdG9rZW4=
428
+ EOF
429
+
430
+ CHALLENGE="$HTTPD_ROOT_PATH/custom-auth.challenge" &&
431
+
432
+ cat >"$HTTPD_ROOT_PATH/custom-auth.challenge" <<-EOF &&
433
+ WWW-Authenticate: FooBar param1="value1" param2="value2"
434
+ WWW-Authenticate: Bearer authorize_uri="id.example.com" p=1 q=0
435
+ WWW-Authenticate: Basic realm="example.com"
436
+ EOF
437
+
438
+ test_config_global credential.helper test-helper &&
439
+ test_must_fail git ls-remote "$HTTPD_URL/custom_auth/repo.git" &&
440
+
441
+ expect_credential_query get <<-EOF &&
442
+ capability[]=authtype
443
+ protocol=http
444
+ host=$HTTPD_DEST
445
+ wwwauth[]=FooBar param1="value1" param2="value2"
446
+ wwwauth[]=Bearer authorize_uri="id.example.com" p=1 q=0
447
+ wwwauth[]=Basic realm="example.com"
448
+ EOF
449
+
450
+ expect_credential_query erase <<-EOF
451
+ capability[]=authtype
452
+ authtype=Bearer
453
+ credential=incorrect-token
454
+ protocol=http
455
+ host=$HTTPD_DEST
456
+ wwwauth[]=FooBar param1="value1" param2="value2"
457
+ wwwauth[]=Bearer authorize_uri="id.example.com" p=1 q=0
458
+ wwwauth[]=Basic realm="example.com"
459
+ EOF
460
+'
461
+
462
test_done