Merge branch 'mg/fix-build-remote-helpers' into maint
[git/mjg.git] / t / t5561-http-backend.sh
blobb5d7fbc3815aed53ec50bdf7f5dbf2c796fed1fe
1 #!/bin/sh
3 test_description='test git-http-backend'
4 . ./test-lib.sh
6 if test -n "$NO_CURL"; then
7 skip_all='skipping test, git built without http support'
8 test_done
9 fi
11 LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'5561'}
12 . "$TEST_DIRECTORY"/lib-httpd.sh
13 start_httpd
15 GET() {
16 curl --include "$HTTPD_URL/$SMART/repo.git/$1" >out 2>/dev/null &&
17 tr '\015' Q <out |
18 sed '
19 s/Q$//
21 ' >act &&
22 echo "HTTP/1.1 $2" >exp &&
23 test_cmp exp act
26 POST() {
27 curl --include --data "$2" \
28 --header "Content-Type: application/x-$1-request" \
29 "$HTTPD_URL/smart/repo.git/$1" >out 2>/dev/null &&
30 tr '\015' Q <out |
31 sed '
32 s/Q$//
34 ' >act &&
35 echo "HTTP/1.1 $3" >exp &&
36 test_cmp exp act
39 log_div() {
40 echo >>"$HTTPD_ROOT_PATH"/access.log
41 echo "### $1" >>"$HTTPD_ROOT_PATH"/access.log
42 echo "###" >>"$HTTPD_ROOT_PATH"/access.log
45 . "$TEST_DIRECTORY"/t556x_common
47 cat >exp <<EOF
49 ### refs/heads/master
50 ###
51 GET /smart/repo.git/refs/heads/master HTTP/1.1 404 -
53 ### getanyfile default
54 ###
55 GET /smart/repo.git/HEAD HTTP/1.1 200
56 GET /smart/repo.git/info/refs HTTP/1.1 200
57 GET /smart/repo.git/objects/info/packs HTTP/1.1 200
58 GET /smart/repo.git/objects/info/alternates HTTP/1.1 200 -
59 GET /smart/repo.git/objects/info/http-alternates HTTP/1.1 200 -
60 GET /smart/repo.git/$LOOSE_URL HTTP/1.1 200
61 GET /smart/repo.git/$PACK_URL HTTP/1.1 200
62 GET /smart/repo.git/$IDX_URL HTTP/1.1 200
64 ### no git-daemon-export-ok
65 ###
66 GET /smart_noexport/repo.git/HEAD HTTP/1.1 404 -
67 GET /smart_noexport/repo.git/info/refs HTTP/1.1 404 -
68 GET /smart_noexport/repo.git/objects/info/packs HTTP/1.1 404 -
69 GET /smart_noexport/repo.git/objects/info/alternates HTTP/1.1 404 -
70 GET /smart_noexport/repo.git/objects/info/http-alternates HTTP/1.1 404 -
71 GET /smart_noexport/repo.git/$LOOSE_URL HTTP/1.1 404 -
72 GET /smart_noexport/repo.git/$PACK_URL HTTP/1.1 404 -
73 GET /smart_noexport/repo.git/$IDX_URL HTTP/1.1 404 -
75 ### git-daemon-export-ok
76 ###
77 GET /smart_noexport/repo.git/HEAD HTTP/1.1 200
78 GET /smart_noexport/repo.git/info/refs HTTP/1.1 200
79 GET /smart_noexport/repo.git/objects/info/packs HTTP/1.1 200
80 GET /smart_noexport/repo.git/objects/info/alternates HTTP/1.1 200 -
81 GET /smart_noexport/repo.git/objects/info/http-alternates HTTP/1.1 200 -
82 GET /smart_noexport/repo.git/$LOOSE_URL HTTP/1.1 200
83 GET /smart_noexport/repo.git/$PACK_URL HTTP/1.1 200
84 GET /smart_noexport/repo.git/$IDX_URL HTTP/1.1 200
86 ### getanyfile true
87 ###
88 GET /smart/repo.git/HEAD HTTP/1.1 200
89 GET /smart/repo.git/info/refs HTTP/1.1 200
90 GET /smart/repo.git/objects/info/packs HTTP/1.1 200
91 GET /smart/repo.git/objects/info/alternates HTTP/1.1 200 -
92 GET /smart/repo.git/objects/info/http-alternates HTTP/1.1 200 -
93 GET /smart/repo.git/$LOOSE_URL HTTP/1.1 200
94 GET /smart/repo.git/$PACK_URL HTTP/1.1 200
95 GET /smart/repo.git/$IDX_URL HTTP/1.1 200
97 ### getanyfile false
98 ###
99 GET /smart/repo.git/HEAD HTTP/1.1 403 -
100 GET /smart/repo.git/info/refs HTTP/1.1 403 -
101 GET /smart/repo.git/objects/info/packs HTTP/1.1 403 -
102 GET /smart/repo.git/objects/info/alternates HTTP/1.1 403 -
103 GET /smart/repo.git/objects/info/http-alternates HTTP/1.1 403 -
104 GET /smart/repo.git/$LOOSE_URL HTTP/1.1 403 -
105 GET /smart/repo.git/$PACK_URL HTTP/1.1 403 -
106 GET /smart/repo.git/$IDX_URL HTTP/1.1 403 -
108 ### uploadpack default
110 GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
111 POST /smart/repo.git/git-upload-pack HTTP/1.1 200 -
113 ### uploadpack true
115 GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
116 POST /smart/repo.git/git-upload-pack HTTP/1.1 200 -
118 ### uploadpack false
120 GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 403 -
121 POST /smart/repo.git/git-upload-pack HTTP/1.1 403 -
123 ### receivepack default
125 GET /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 403 -
126 POST /smart/repo.git/git-receive-pack HTTP/1.1 403 -
128 ### receivepack true
130 GET /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
131 POST /smart/repo.git/git-receive-pack HTTP/1.1 200 -
133 ### receivepack false
135 GET /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 403 -
136 POST /smart/repo.git/git-receive-pack HTTP/1.1 403 -
138 test_expect_success 'server request log matches test results' '
139 sed -e "
140 s/^.* \"//
141 s/\"//
142 s/ [1-9][0-9]*\$//
143 s/^GET /GET /
144 " >act <"$HTTPD_ROOT_PATH"/access.log &&
145 test_cmp exp act
148 stop_httpd
149 test_done