Merge branch 'pt/am-tests'
[alt-git.git] / t / t5561-http-backend.sh
blob19afe966986cdc72cf8fc23f113bd77a8128f382
1 #!/bin/sh
3 test_description='test git-http-backend'
4 . ./test-lib.sh
5 . "$TEST_DIRECTORY"/lib-httpd.sh
6 start_httpd
8 GET() {
9 curl --include "$HTTPD_URL/$SMART/repo.git/$1" >out 2>/dev/null &&
10 tr '\015' Q <out |
11 sed '
12 s/Q$//
14 ' >act &&
15 echo "HTTP/1.1 $2" >exp &&
16 test_cmp exp act
19 POST() {
20 curl --include --data "$2" \
21 --header "Content-Type: application/x-$1-request" \
22 "$HTTPD_URL/smart/repo.git/$1" >out 2>/dev/null &&
23 tr '\015' Q <out |
24 sed '
25 s/Q$//
27 ' >act &&
28 echo "HTTP/1.1 $3" >exp &&
29 test_cmp exp act
32 log_div() {
33 echo >>"$HTTPD_ROOT_PATH"/access.log
34 echo "### $1" >>"$HTTPD_ROOT_PATH"/access.log
35 echo "###" >>"$HTTPD_ROOT_PATH"/access.log
38 . "$TEST_DIRECTORY"/t556x_common
40 cat >exp <<EOF
42 ### refs/heads/master
43 ###
44 GET /smart/repo.git/refs/heads/master HTTP/1.1 404 -
46 ### getanyfile default
47 ###
48 GET /smart/repo.git/HEAD HTTP/1.1 200
49 GET /smart/repo.git/info/refs HTTP/1.1 200
50 GET /smart/repo.git/objects/info/packs HTTP/1.1 200
51 GET /smart/repo.git/objects/info/alternates HTTP/1.1 200 -
52 GET /smart/repo.git/objects/info/http-alternates HTTP/1.1 200 -
53 GET /smart/repo.git/$LOOSE_URL HTTP/1.1 200
54 GET /smart/repo.git/$PACK_URL HTTP/1.1 200
55 GET /smart/repo.git/$IDX_URL HTTP/1.1 200
57 ### no git-daemon-export-ok
58 ###
59 GET /smart_noexport/repo.git/HEAD HTTP/1.1 404 -
60 GET /smart_noexport/repo.git/info/refs HTTP/1.1 404 -
61 GET /smart_noexport/repo.git/objects/info/packs HTTP/1.1 404 -
62 GET /smart_noexport/repo.git/objects/info/alternates HTTP/1.1 404 -
63 GET /smart_noexport/repo.git/objects/info/http-alternates HTTP/1.1 404 -
64 GET /smart_noexport/repo.git/$LOOSE_URL HTTP/1.1 404 -
65 GET /smart_noexport/repo.git/$PACK_URL HTTP/1.1 404 -
66 GET /smart_noexport/repo.git/$IDX_URL HTTP/1.1 404 -
68 ### git-daemon-export-ok
69 ###
70 GET /smart_noexport/repo.git/HEAD HTTP/1.1 200
71 GET /smart_noexport/repo.git/info/refs HTTP/1.1 200
72 GET /smart_noexport/repo.git/objects/info/packs HTTP/1.1 200
73 GET /smart_noexport/repo.git/objects/info/alternates HTTP/1.1 200 -
74 GET /smart_noexport/repo.git/objects/info/http-alternates HTTP/1.1 200 -
75 GET /smart_noexport/repo.git/$LOOSE_URL HTTP/1.1 200
76 GET /smart_noexport/repo.git/$PACK_URL HTTP/1.1 200
77 GET /smart_noexport/repo.git/$IDX_URL HTTP/1.1 200
79 ### getanyfile true
80 ###
81 GET /smart/repo.git/HEAD HTTP/1.1 200
82 GET /smart/repo.git/info/refs HTTP/1.1 200
83 GET /smart/repo.git/objects/info/packs HTTP/1.1 200
84 GET /smart/repo.git/objects/info/alternates HTTP/1.1 200 -
85 GET /smart/repo.git/objects/info/http-alternates HTTP/1.1 200 -
86 GET /smart/repo.git/$LOOSE_URL HTTP/1.1 200
87 GET /smart/repo.git/$PACK_URL HTTP/1.1 200
88 GET /smart/repo.git/$IDX_URL HTTP/1.1 200
90 ### getanyfile false
91 ###
92 GET /smart/repo.git/HEAD HTTP/1.1 403 -
93 GET /smart/repo.git/info/refs HTTP/1.1 403 -
94 GET /smart/repo.git/objects/info/packs HTTP/1.1 403 -
95 GET /smart/repo.git/objects/info/alternates HTTP/1.1 403 -
96 GET /smart/repo.git/objects/info/http-alternates HTTP/1.1 403 -
97 GET /smart/repo.git/$LOOSE_URL HTTP/1.1 403 -
98 GET /smart/repo.git/$PACK_URL HTTP/1.1 403 -
99 GET /smart/repo.git/$IDX_URL HTTP/1.1 403 -
101 ### uploadpack default
103 GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
104 POST /smart/repo.git/git-upload-pack HTTP/1.1 200 -
106 ### uploadpack true
108 GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
109 POST /smart/repo.git/git-upload-pack HTTP/1.1 200 -
111 ### uploadpack false
113 GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 403 -
114 POST /smart/repo.git/git-upload-pack HTTP/1.1 403 -
116 ### receivepack default
118 GET /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 403 -
119 POST /smart/repo.git/git-receive-pack HTTP/1.1 403 -
121 ### receivepack true
123 GET /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
124 POST /smart/repo.git/git-receive-pack HTTP/1.1 200 -
126 ### receivepack false
128 GET /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 403 -
129 POST /smart/repo.git/git-receive-pack HTTP/1.1 403 -
131 test_expect_success 'server request log matches test results' '
132 sed -e "
133 s/^.* \"//
134 s/\"//
135 s/ [1-9][0-9]*\$//
136 s/^GET /GET /
137 " >act <"$HTTPD_ROOT_PATH"/access.log &&
138 test_cmp exp act
141 stop_httpd
142 test_done