From 0aff719f489771c5e52259394d011c51317b118f Mon Sep 17 00:00:00 2001 From: Christopher Tiwald Date: Thu, 12 Apr 2012 13:56:28 -0400 Subject: Fix httpd tests that broke when non-ff push advice changed Signed-off-by: Christopher Tiwald Signed-off-by: Junio C Hamano --- t/lib-httpd.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/lib-httpd.sh') diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh index f7dc0781d5..094d490893 100644 --- a/t/lib-httpd.sh +++ b/t/lib-httpd.sh @@ -160,6 +160,6 @@ test_http_push_nonff() { ' test_expect_success 'non-fast-forward push shows help message' ' - test_i18ngrep "To prevent you from losing history, non-fast-forward updates were rejected" output + test_i18ngrep "Updates were rejected because" output ' } -- cgit v1.2.1 From f628825481b706baa3d9bf871a081cb1285c2778 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Tue, 24 Jul 2012 09:43:59 -0400 Subject: t/lib-httpd: handle running under --valgrind Running the http tests with valgrind does not work for two reasons: 1. Apache complains about following the symbolic link from git-http-backend to valgrind.sh. 2. Apache does not pass through the GIT_VALGRIND variable to the backend CGI. This patch fixes both problems. Unfortunately, there is a slight hack we need to handle passing environment variables through Apache. If we just tell it: PassEnv GIT_VALGRIND then Apache will complain when GIT_VALGRIND is not set. If we try: SetEnv GIT_VALGRIND ${GIT_VALGRIND} then when GIT_VALGRIND is not set, it will pass through the literal "${GIT_VALGRIND}". Instead, we now unconditionally pass through GIT_VALGRIND from lib-httpd.sh into apache, even if it is empty. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/lib-httpd.sh | 4 ++++ 1 file changed, 4 insertions(+) (limited to 't/lib-httpd.sh') diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh index 094d490893..d773542680 100644 --- a/t/lib-httpd.sh +++ b/t/lib-httpd.sh @@ -43,6 +43,10 @@ TEST_PATH="$TEST_DIRECTORY"/lib-httpd HTTPD_ROOT_PATH="$PWD"/httpd HTTPD_DOCUMENT_ROOT_PATH=$HTTPD_ROOT_PATH/www +# hack to suppress apache PassEnv warnings +GIT_VALGRIND=$GIT_VALGRIND; export GIT_VALGRIND +GIT_VALGRIND_OPTIONS=$GIT_VALGRIND_OPTIONS; export GIT_VALGRIND_OPTIONS + if ! test -x "$LIB_HTTPD_PATH" then skip_all="skipping test, no web server found at '$LIB_HTTPD_PATH'" -- cgit v1.2.1 From e837936c7c08ac5829bc53761ecb57d18d458edd Mon Sep 17 00:00:00 2001 From: Jeff King Date: Mon, 27 Aug 2012 09:24:31 -0400 Subject: t5550: factor out http auth setup The t5550 script sets up a nice askpass helper for simulating user input and checking what git prompted for. Let's make it available to other http scripts by migrating it to lib-httpd. We can use this immediately in t5540 to make our tests more robust (previously, we did not check at all that hitting the password-protected repo actually involved a password). Unfortunately, we end up failing the test because the current code erroneously prompts twice (once for git-remote-http, and then again when the former spawns git-http-push). More importantly, though, it will let us easily add smart-http authentication tests in t5541 and t5551; we currently do not test smart-http authentication at all. As part of making it generic, let's always look for and store auxiliary askpass files at the top-level trash directory; this makes it compatible with t5540, which runs some tests from sub-repositories. We can abstract away the ugliness with a short helper function. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/lib-httpd.sh | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 't/lib-httpd.sh') diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh index 094d490893..0f31ef9be4 100644 --- a/t/lib-httpd.sh +++ b/t/lib-httpd.sh @@ -163,3 +163,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" +} -- cgit v1.2.1 From 4656bf47fca857df51b5d6f4b7b052192b3b2317 Mon Sep 17 00:00:00 2001 From: Shawn Pearce Date: Thu, 31 Jan 2013 13:02:07 -0800 Subject: Verify Content-Type from smart HTTP servers Before parsing a suspected smart-HTTP response verify the returned Content-Type matches the standard. This protects a client from attempting to process a payload that smells like a smart-HTTP server response. JGit has been doing this check on all responses since the dawn of time. I mistakenly failed to include it in git-core when smart HTTP was introduced. At the time I didn't know how to get the Content-Type from libcurl. I punted, meant to circle back and fix this, and just plain forgot about it. Signed-off-by: Shawn Pearce Signed-off-by: Junio C Hamano --- t/lib-httpd.sh | 1 + 1 file changed, 1 insertion(+) (limited to 't/lib-httpd.sh') diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh index 02f442bfad..895b9258b0 100644 --- a/t/lib-httpd.sh +++ b/t/lib-httpd.sh @@ -80,6 +80,7 @@ fi prepare_httpd() { mkdir -p "$HTTPD_DOCUMENT_ROOT_PATH" cp "$TEST_PATH"/passwd "$HTTPD_ROOT_PATH" + cp "$TEST_PATH"/broken-smart-http.sh "$HTTPD_ROOT_PATH" ln -s "$LIB_HTTPD_MODULE_PATH" "$HTTPD_ROOT_PATH/modules" -- cgit v1.2.1