git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
blob f4520902160abc092cda6a268fb564b69ad451df 2587 bytes (raw)
name: t/t5560-http-backend-noserver.sh 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
 
#!/bin/sh

test_description='test git-http-backend-noserver'
. ./test-lib.sh

HTTPD_DOCUMENT_ROOT_PATH="$TRASH_DIRECTORY"

if test_have_prereq GREP_STRIPS_CR
then
	GREP_OPTIONS=-U
	export GREP_OPTIONS
fi

run_backend() {
	echo "$2" |
	QUERY_STRING="${1#*[?]}" \
	PATH_TRANSLATED="$HTTPD_DOCUMENT_ROOT_PATH/${1%%[?]*}" \
	git http-backend >act.out 2>act.err
}

GET() {
	REQUEST_METHOD="GET" && export REQUEST_METHOD &&
	run_backend "/repo.git/$1" &&
	sane_unset REQUEST_METHOD &&
	if ! grep "Status" act.out >act
	then
		printf "Status: 200 OK\r\n" >act
	fi
	printf "Status: $2\r\n" >exp &&
	test_cmp exp act
}

POST() {
	REQUEST_METHOD="POST" && export REQUEST_METHOD &&
	CONTENT_TYPE="application/x-$1-request" && export CONTENT_TYPE &&
	run_backend "/repo.git/$1" "$2" &&
	sane_unset REQUEST_METHOD &&
	sane_unset CONTENT_TYPE &&
	if ! grep "Status" act.out >act
	then
		printf "Status: 200 OK\r\n" >act
	fi
	printf "Status: $3\r\n" >exp &&
	test_cmp exp act
}

. "$TEST_DIRECTORY"/t556x_common

expect_aliased() {
	REQUEST_METHOD="GET" && export REQUEST_METHOD &&
	if test $1 = 0; then
		run_backend "$2"
	else
		run_backend "$2" &&
		echo "fatal: '$2': aliased" >exp.err &&
		test_cmp exp.err act.err
	fi
	unset REQUEST_METHOD
}

test_expect_success 'http-backend blocks bad PATH_INFO' '
	config http.getanyfile true &&

	expect_aliased 0 /repo.git/HEAD &&

	expect_aliased 1 /repo.git/../HEAD &&
	expect_aliased 1 /../etc/passwd &&
	expect_aliased 1 ../etc/passwd &&
	expect_aliased 1 /etc//passwd &&
	expect_aliased 1 /etc/./passwd &&
	expect_aliased 1 //domain/data.txt
'

# overrides existing definition for further cases
run_backend() {
	CONTENT_LENGTH="${#2}" && export CONTENT_LENGTH &&
	( echo "$2" && cat /dev/zero ) |
	QUERY_STRING="${1#*[?]}" \
	PATH_TRANSLATED="$HTTPD_DOCUMENT_ROOT_PATH/${1%%[?]*}" \
	git http-backend >act.out 2>act.err
}

test_expect_success 'CONTENT_LENGTH set and infinite input' '
	config http.uploadpack true &&
	GET info/refs?service=git-upload-pack "200 OK"	&&
	! grep "fatal:.*" act.err &&
	POST git-upload-pack 0000 "200 OK" &&
	! grep "fatal:.*" act.err
'

test_expect_success 'CONTENT_LENGTH overflow ssite_t' '
	NOT_FIT_IN_SSIZE=`"$GIT_BUILD_DIR/t/helper/test-print-values" "(size_t)(-20)"` &&
	env \
		CONTENT_TYPE=application/x-git-upload-pack-request \
		QUERY_STRING=/repo.git/git-upload-pack \
		PATH_TRANSLATED="$PWD"/.git/git-upload-pack \
		GIT_HTTP_EXPORT_ALL=TRUE \
		REQUEST_METHOD=POST \
		CONTENT_LENGTH="$NOT_FIT_IN_SSIZE" \
		git http-backend </dev/zero >/dev/null 2>err &&
	grep -q "fatal:.*CONTENT_LENGTH" err
'

test_done

debug log:

solving f452090216 ...
found f452090216 in https://public-inbox.org/git/20171126193813.12531-3-max@max630.net/ ||
	https://public-inbox.org/git/20171126015448.24111-3-max@max630.net/ ||
	https://public-inbox.org/git/20171126014719.23728-3-max@max630.net/
found 9fafcf1945 in https://80x24.org/mirrors/git.git
preparing index
index prepared:
100755 9fafcf194589218e28b894a7bd9e83c9a1893fbf	t/t5560-http-backend-noserver.sh

applying [1/1] https://public-inbox.org/git/20171126193813.12531-3-max@max630.net/
diff --git a/t/t5560-http-backend-noserver.sh b/t/t5560-http-backend-noserver.sh
index 9fafcf1945..f452090216 100755

Checking patch t/t5560-http-backend-noserver.sh...
Applied patch t/t5560-http-backend-noserver.sh cleanly.

skipping https://public-inbox.org/git/20171126015448.24111-3-max@max630.net/ for f452090216
skipping https://public-inbox.org/git/20171126014719.23728-3-max@max630.net/ for f452090216
index at:
100755 f4520902160abc092cda6a268fb564b69ad451df	t/t5560-http-backend-noserver.sh

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).