]> git.ipfire.org Git - thirdparty/git.git/blob - t/t5561-http-backend.sh
Merge branch 'ls/editor-waiting-message'
[thirdparty/git.git] / t / t5561-http-backend.sh
1 #!/bin/sh
2
3 test_description='test git-http-backend'
4 . ./test-lib.sh
5 . "$TEST_DIRECTORY"/lib-httpd.sh
6 start_httpd
7
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$//
13 1q
14 ' >act &&
15 echo "HTTP/1.1 $2" >exp &&
16 test_cmp exp act
17 }
18
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$//
26 1q
27 ' >act &&
28 echo "HTTP/1.1 $3" >exp &&
29 test_cmp exp act
30 }
31
32 . "$TEST_DIRECTORY"/t556x_common
33
34 grep '^[^#]' >exp <<EOF
35
36 ### refs/heads/master
37 ###
38 GET /smart/repo.git/refs/heads/master HTTP/1.1 404 -
39
40 ### getanyfile default
41 ###
42 GET /smart/repo.git/HEAD HTTP/1.1 200
43 GET /smart/repo.git/info/refs HTTP/1.1 200
44 GET /smart/repo.git/objects/info/packs HTTP/1.1 200
45 GET /smart/repo.git/objects/info/alternates HTTP/1.1 200 -
46 GET /smart/repo.git/objects/info/http-alternates HTTP/1.1 200 -
47 GET /smart/repo.git/$LOOSE_URL HTTP/1.1 200
48 GET /smart/repo.git/$PACK_URL HTTP/1.1 200
49 GET /smart/repo.git/$IDX_URL HTTP/1.1 200
50
51 ### no git-daemon-export-ok
52 ###
53 GET /smart_noexport/repo.git/HEAD HTTP/1.1 404 -
54 GET /smart_noexport/repo.git/info/refs HTTP/1.1 404 -
55 GET /smart_noexport/repo.git/objects/info/packs HTTP/1.1 404 -
56 GET /smart_noexport/repo.git/objects/info/alternates HTTP/1.1 404 -
57 GET /smart_noexport/repo.git/objects/info/http-alternates HTTP/1.1 404 -
58 GET /smart_noexport/repo.git/$LOOSE_URL HTTP/1.1 404 -
59 GET /smart_noexport/repo.git/$PACK_URL HTTP/1.1 404 -
60 GET /smart_noexport/repo.git/$IDX_URL HTTP/1.1 404 -
61
62 ### git-daemon-export-ok
63 ###
64 GET /smart_noexport/repo.git/HEAD HTTP/1.1 200
65 GET /smart_noexport/repo.git/info/refs HTTP/1.1 200
66 GET /smart_noexport/repo.git/objects/info/packs HTTP/1.1 200
67 GET /smart_noexport/repo.git/objects/info/alternates HTTP/1.1 200 -
68 GET /smart_noexport/repo.git/objects/info/http-alternates HTTP/1.1 200 -
69 GET /smart_noexport/repo.git/$LOOSE_URL HTTP/1.1 200
70 GET /smart_noexport/repo.git/$PACK_URL HTTP/1.1 200
71 GET /smart_noexport/repo.git/$IDX_URL HTTP/1.1 200
72
73 ### getanyfile true
74 ###
75 GET /smart/repo.git/HEAD HTTP/1.1 200
76 GET /smart/repo.git/info/refs HTTP/1.1 200
77 GET /smart/repo.git/objects/info/packs HTTP/1.1 200
78 GET /smart/repo.git/objects/info/alternates HTTP/1.1 200 -
79 GET /smart/repo.git/objects/info/http-alternates HTTP/1.1 200 -
80 GET /smart/repo.git/$LOOSE_URL HTTP/1.1 200
81 GET /smart/repo.git/$PACK_URL HTTP/1.1 200
82 GET /smart/repo.git/$IDX_URL HTTP/1.1 200
83
84 ### getanyfile false
85 ###
86 GET /smart/repo.git/HEAD HTTP/1.1 403 -
87 GET /smart/repo.git/info/refs HTTP/1.1 403 -
88 GET /smart/repo.git/objects/info/packs HTTP/1.1 403 -
89 GET /smart/repo.git/objects/info/alternates HTTP/1.1 403 -
90 GET /smart/repo.git/objects/info/http-alternates HTTP/1.1 403 -
91 GET /smart/repo.git/$LOOSE_URL HTTP/1.1 403 -
92 GET /smart/repo.git/$PACK_URL HTTP/1.1 403 -
93 GET /smart/repo.git/$IDX_URL HTTP/1.1 403 -
94
95 ### uploadpack default
96 ###
97 GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
98 POST /smart/repo.git/git-upload-pack HTTP/1.1 200 -
99
100 ### uploadpack true
101 ###
102 GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
103 POST /smart/repo.git/git-upload-pack HTTP/1.1 200 -
104
105 ### uploadpack false
106 ###
107 GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 403 -
108 POST /smart/repo.git/git-upload-pack HTTP/1.1 403 -
109
110 ### receivepack default
111 ###
112 GET /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 403 -
113 POST /smart/repo.git/git-receive-pack HTTP/1.1 403 -
114
115 ### receivepack true
116 ###
117 GET /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
118 POST /smart/repo.git/git-receive-pack HTTP/1.1 200 -
119
120 ### receivepack false
121 ###
122 GET /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 403 -
123 POST /smart/repo.git/git-receive-pack HTTP/1.1 403 -
124 EOF
125 test_expect_success 'server request log matches test results' '
126 sed -e "
127 s/^.* \"//
128 s/\"//
129 s/ [1-9][0-9]*\$//
130 s/^GET /GET /
131 " >act <"$HTTPD_ROOT_PATH"/access.log &&
132 test_cmp exp act
133 '
134
135 stop_httpd
136 test_done