summaryrefslogtreecommitdiff
path: root/t/lib-httpd.sh
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2012-09-07 11:09:49 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2012-09-07 11:09:50 -0700
commite6dd70e9bfef40d545cb0f452f082bde562e8785 (patch)
tree6ca29bfd8d3a36bfae9508c8756ff81e3a78b224 /t/lib-httpd.sh
parentMerge branch 'jc/maint-doc-checkout-b-always-takes-branch-name' (diff)
parenthttp: prompt for credentials on failed POST (diff)
downloadtgif-e6dd70e9bfef40d545cb0f452f082bde562e8785.tar.xz
Merge branch 'jk/maint-http-half-auth-push'
Pushing to smart HTTP server with recent Git fails without having the username in the URL to force authentication, if the server is configured to allow GET anonymously, while requiring authentication for POST. * jk/maint-http-half-auth-push: http: prompt for credentials on failed POST http: factor out http error code handling t: test http access to "half-auth" repositories t: test basic smart-http authentication t/lib-httpd: recognize */smart/* repos as smart-http t/lib-httpd: only route auth/dumb to dumb repos t5550: factor out http auth setup t5550: put auth-required repo in auth/dumb
Diffstat (limited to 't/lib-httpd.sh')
-rw-r--r--t/lib-httpd.sh39
1 files changed, 39 insertions, 0 deletions
diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh
index d773542680..02f442bfad 100644
--- a/t/lib-httpd.sh
+++ b/t/lib-httpd.sh
@@ -167,3 +167,42 @@ test_http_push_nonff() {
test_i18ngrep "Updates were rejected because" output
'
}
+
+setup_askpass_helper() {
+ test_expect_success 'setup askpass helper' '
+ write_script "$TRASH_DIRECTORY/askpass" <<-\EOF &&
+ echo >>"$TRASH_DIRECTORY/askpass-query" "askpass: $*" &&
+ cat "$TRASH_DIRECTORY/askpass-response"
+ EOF
+ GIT_ASKPASS="$TRASH_DIRECTORY/askpass" &&
+ export GIT_ASKPASS &&
+ export TRASH_DIRECTORY
+ '
+}
+
+set_askpass() {
+ >"$TRASH_DIRECTORY/askpass-query" &&
+ echo "$*" >"$TRASH_DIRECTORY/askpass-response"
+}
+
+expect_askpass() {
+ dest=$HTTPD_DEST
+ {
+ case "$1" in
+ none)
+ ;;
+ pass)
+ echo "askpass: Password for 'http://$2@$dest': "
+ ;;
+ both)
+ echo "askpass: Username for 'http://$dest': "
+ echo "askpass: Password for 'http://$2@$dest': "
+ ;;
+ *)
+ false
+ ;;
+ esac
+ } >"$TRASH_DIRECTORY/askpass-expect" &&
+ test_cmp "$TRASH_DIRECTORY/askpass-expect" \
+ "$TRASH_DIRECTORY/askpass-query"
+}