Sync with maint
[git.git] / t / t5561-http-backend.sh
blobd23fb0238483520e77004a208f15db808941b4af
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 . "$TEST_DIRECTORY"/lib-httpd.sh
12 start_httpd
14 GET() {
15 curl --include "$HTTPD_URL/$SMART/repo.git/$1" >out 2>/dev/null &&
16 tr '\015' Q <out |
17 sed '
18 s/Q$//
20 ' >act &&
21 echo "HTTP/1.1 $2" >exp &&
22 test_cmp exp act
25 POST() {
26 curl --include --data "$2" \
27 --header "Content-Type: application/x-$1-request" \
28 "$HTTPD_URL/smart/repo.git/$1" >out 2>/dev/null &&
29 tr '\015' Q <out |
30 sed '
31 s/Q$//
33 ' >act &&
34 echo "HTTP/1.1 $3" >exp &&
35 test_cmp exp act
38 log_div() {
39 echo >>"$HTTPD_ROOT_PATH"/access.log
40 echo "### $1" >>"$HTTPD_ROOT_PATH"/access.log
41 echo "###" >>"$HTTPD_ROOT_PATH"/access.log
44 . "$TEST_DIRECTORY"/t556x_common
46 cat >exp <<EOF
48 ### refs/heads/master
49 ###
50 GET /smart/repo.git/refs/heads/master HTTP/1.1 404 -
52 ### getanyfile default
53 ###
54 GET /smart/repo.git/HEAD HTTP/1.1 200
55 GET /smart/repo.git/info/refs HTTP/1.1 200
56 GET /smart/repo.git/objects/info/packs HTTP/1.1 200
57 GET /smart/repo.git/objects/info/alternates HTTP/1.1 200 -
58 GET /smart/repo.git/objects/info/http-alternates HTTP/1.1 200 -
59 GET /smart/repo.git/$LOOSE_URL HTTP/1.1 200
60 GET /smart/repo.git/$PACK_URL HTTP/1.1 200
61 GET /smart/repo.git/$IDX_URL HTTP/1.1 200
63 ### no git-daemon-export-ok
64 ###
65 GET /smart_noexport/repo.git/HEAD HTTP/1.1 404 -
66 GET /smart_noexport/repo.git/info/refs HTTP/1.1 404 -
67 GET /smart_noexport/repo.git/objects/info/packs HTTP/1.1 404 -
68 GET /smart_noexport/repo.git/objects/info/alternates HTTP/1.1 404 -
69 GET /smart_noexport/repo.git/objects/info/http-alternates HTTP/1.1 404 -
70 GET /smart_noexport/repo.git/$LOOSE_URL HTTP/1.1 404 -
71 GET /smart_noexport/repo.git/$PACK_URL HTTP/1.1 404 -
72 GET /smart_noexport/repo.git/$IDX_URL HTTP/1.1 404 -
74 ### git-daemon-export-ok
75 ###
76 GET /smart_noexport/repo.git/HEAD HTTP/1.1 200
77 GET /smart_noexport/repo.git/info/refs HTTP/1.1 200
78 GET /smart_noexport/repo.git/objects/info/packs HTTP/1.1 200
79 GET /smart_noexport/repo.git/objects/info/alternates HTTP/1.1 200 -
80 GET /smart_noexport/repo.git/objects/info/http-alternates HTTP/1.1 200 -
81 GET /smart_noexport/repo.git/$LOOSE_URL HTTP/1.1 200
82 GET /smart_noexport/repo.git/$PACK_URL HTTP/1.1 200
83 GET /smart_noexport/repo.git/$IDX_URL HTTP/1.1 200
85 ### getanyfile true
86 ###
87 GET /smart/repo.git/HEAD HTTP/1.1 200
88 GET /smart/repo.git/info/refs HTTP/1.1 200
89 GET /smart/repo.git/objects/info/packs HTTP/1.1 200
90 GET /smart/repo.git/objects/info/alternates HTTP/1.1 200 -
91 GET /smart/repo.git/objects/info/http-alternates HTTP/1.1 200 -
92 GET /smart/repo.git/$LOOSE_URL HTTP/1.1 200
93 GET /smart/repo.git/$PACK_URL HTTP/1.1 200
94 GET /smart/repo.git/$IDX_URL HTTP/1.1 200
96 ### getanyfile false
97 ###
98 GET /smart/repo.git/HEAD HTTP/1.1 403 -
99 GET /smart/repo.git/info/refs HTTP/1.1 403 -
100 GET /smart/repo.git/objects/info/packs HTTP/1.1 403 -
101 GET /smart/repo.git/objects/info/alternates HTTP/1.1 403 -
102 GET /smart/repo.git/objects/info/http-alternates HTTP/1.1 403 -
103 GET /smart/repo.git/$LOOSE_URL HTTP/1.1 403 -
104 GET /smart/repo.git/$PACK_URL HTTP/1.1 403 -
105 GET /smart/repo.git/$IDX_URL HTTP/1.1 403 -
107 ### uploadpack default
109 GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
110 POST /smart/repo.git/git-upload-pack HTTP/1.1 200 -
112 ### uploadpack true
114 GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
115 POST /smart/repo.git/git-upload-pack HTTP/1.1 200 -
117 ### uploadpack false
119 GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 403 -
120 POST /smart/repo.git/git-upload-pack HTTP/1.1 403 -
122 ### receivepack default
124 GET /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 403 -
125 POST /smart/repo.git/git-receive-pack HTTP/1.1 403 -
127 ### receivepack true
129 GET /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
130 POST /smart/repo.git/git-receive-pack HTTP/1.1 200 -
132 ### receivepack false
134 GET /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 403 -
135 POST /smart/repo.git/git-receive-pack HTTP/1.1 403 -
137 test_expect_success 'server request log matches test results' '
138 sed -e "
139 s/^.* \"//
140 s/\"//
141 s/ [1-9][0-9]*\$//
142 s/^GET /GET /
143 " >act <"$HTTPD_ROOT_PATH"/access.log &&
144 test_cmp exp act
147 stop_httpd
148 test_done