bloom: ignore renames when computing changed paths
[git.git] / t / t9501-gitweb-standalone-http-status.sh
blob2a0ffed870dd8634466bccfd0e435b5a304f8818
1 #!/bin/sh
3 # Copyright (c) 2009 Mark Rada
6 test_description='gitweb as standalone script (http status tests).
8 This test runs gitweb (git web interface) as a CGI script from the
9 commandline, and checks that it returns the expected HTTP status
10 code and message.'
13 . ./gitweb-lib.sh
16 # Gitweb only provides the functionality tested by the 'modification times'
17 # tests if it can access a date parser from one of these modules:
19 perl -MHTTP::Date -e 0 >/dev/null 2>&1 && test_set_prereq DATE_PARSER
20 perl -MTime::ParseDate -e 0 >/dev/null 2>&1 && test_set_prereq DATE_PARSER
22 # ----------------------------------------------------------------------
23 # snapshot settings
25 test_expect_success 'setup' "
26 test_commit 'SnapshotTests' 'i can has snapshot'
30 cat >>gitweb_config.perl <<\EOF
31 $feature{'snapshot'}{'override'} = 0;
32 EOF
34 test_expect_success \
35 'snapshots: tgz only default format enabled' \
36 'gitweb_run "p=.git;a=snapshot;h=HEAD;sf=tgz" &&
37 grep "Status: 200 OK" gitweb.output &&
38 gitweb_run "p=.git;a=snapshot;h=HEAD;sf=tbz2" &&
39 grep "403 - Unsupported snapshot format" gitweb.output &&
40 gitweb_run "p=.git;a=snapshot;h=HEAD;sf=txz" &&
41 grep "403 - Snapshot format not allowed" gitweb.output &&
42 gitweb_run "p=.git;a=snapshot;h=HEAD;sf=zip" &&
43 grep "403 - Unsupported snapshot format" gitweb.output'
46 cat >>gitweb_config.perl <<\EOF
47 $feature{'snapshot'}{'default'} = ['tgz','tbz2','txz','zip'];
48 EOF
50 test_expect_success \
51 'snapshots: all enabled in default, use default disabled value' \
52 'gitweb_run "p=.git;a=snapshot;h=HEAD;sf=tgz" &&
53 grep "Status: 200 OK" gitweb.output &&
54 gitweb_run "p=.git;a=snapshot;h=HEAD;sf=tbz2" &&
55 grep "Status: 200 OK" gitweb.output &&
56 gitweb_run "p=.git;a=snapshot;h=HEAD;sf=txz" &&
57 grep "403 - Snapshot format not allowed" gitweb.output &&
58 gitweb_run "p=.git;a=snapshot;h=HEAD;sf=zip" &&
59 grep "Status: 200 OK" gitweb.output'
62 cat >>gitweb_config.perl <<\EOF
63 $known_snapshot_formats{'zip'}{'disabled'} = 1;
64 EOF
66 test_expect_success \
67 'snapshots: zip explicitly disabled' \
68 'gitweb_run "p=.git;a=snapshot;h=HEAD;sf=zip" &&
69 grep "403 - Snapshot format not allowed" gitweb.output'
70 test_debug 'cat gitweb.output'
73 cat >>gitweb_config.perl <<\EOF
74 $known_snapshot_formats{'tgz'}{'disabled'} = 0;
75 EOF
77 test_expect_success \
78 'snapshots: tgz explicitly enabled' \
79 'gitweb_run "p=.git;a=snapshot;h=HEAD;sf=tgz" &&
80 grep "Status: 200 OK" gitweb.output'
81 test_debug 'cat gitweb.headers'
84 # ----------------------------------------------------------------------
85 # snapshot hash ids
87 test_expect_success 'snapshots: good tree-ish id' '
88 gitweb_run "p=.git;a=snapshot;h=master;sf=tgz" &&
89 grep "Status: 200 OK" gitweb.output
91 test_debug 'cat gitweb.headers'
93 test_expect_success 'snapshots: bad tree-ish id' '
94 gitweb_run "p=.git;a=snapshot;h=frizzumFrazzum;sf=tgz" &&
95 grep "404 - Object does not exist" gitweb.output
97 test_debug 'cat gitweb.output'
99 test_expect_success 'snapshots: bad tree-ish id (tagged object)' '
100 echo object > tag-object &&
101 git add tag-object &&
102 test_tick && git commit -m "Object to be tagged" &&
103 git tag tagged-object $(git hash-object tag-object) &&
104 gitweb_run "p=.git;a=snapshot;h=tagged-object;sf=tgz" &&
105 grep "400 - Object is not a tree-ish" gitweb.output
107 test_debug 'cat gitweb.output'
109 test_expect_success 'snapshots: good object id' '
110 ID=$(git rev-parse --verify HEAD) &&
111 gitweb_run "p=.git;a=snapshot;h=$ID;sf=tgz" &&
112 grep "Status: 200 OK" gitweb.output
114 test_debug 'cat gitweb.headers'
116 test_expect_success 'snapshots: bad object id' '
117 gitweb_run "p=.git;a=snapshot;h=abcdef01234;sf=tgz" &&
118 grep "404 - Object does not exist" gitweb.output
120 test_debug 'cat gitweb.output'
122 # ----------------------------------------------------------------------
123 # modification times (Last-Modified and If-Modified-Since)
125 test_expect_success DATE_PARSER 'modification: feed last-modified' '
126 gitweb_run "p=.git;a=atom;h=master" &&
127 grep "Status: 200 OK" gitweb.headers &&
128 grep "Last-modified: Thu, 7 Apr 2005 22:14:13 +0000" gitweb.headers
130 test_debug 'cat gitweb.headers'
132 test_expect_success DATE_PARSER 'modification: feed if-modified-since (modified)' '
133 HTTP_IF_MODIFIED_SINCE="Wed, 6 Apr 2005 22:14:13 +0000" &&
134 export HTTP_IF_MODIFIED_SINCE &&
135 test_when_finished "unset HTTP_IF_MODIFIED_SINCE" &&
136 gitweb_run "p=.git;a=atom;h=master" &&
137 grep "Status: 200 OK" gitweb.headers
139 test_debug 'cat gitweb.headers'
141 test_expect_success DATE_PARSER 'modification: feed if-modified-since (unmodified)' '
142 HTTP_IF_MODIFIED_SINCE="Thu, 7 Apr 2005 22:14:13 +0000" &&
143 export HTTP_IF_MODIFIED_SINCE &&
144 test_when_finished "unset HTTP_IF_MODIFIED_SINCE" &&
145 gitweb_run "p=.git;a=atom;h=master" &&
146 grep "Status: 304 Not Modified" gitweb.headers
148 test_debug 'cat gitweb.headers'
150 test_expect_success DATE_PARSER 'modification: snapshot last-modified' '
151 gitweb_run "p=.git;a=snapshot;h=master;sf=tgz" &&
152 grep "Status: 200 OK" gitweb.headers &&
153 grep "Last-modified: Thu, 7 Apr 2005 22:14:13 +0000" gitweb.headers
155 test_debug 'cat gitweb.headers'
157 test_expect_success DATE_PARSER 'modification: snapshot if-modified-since (modified)' '
158 HTTP_IF_MODIFIED_SINCE="Wed, 6 Apr 2005 22:14:13 +0000" &&
159 export HTTP_IF_MODIFIED_SINCE &&
160 test_when_finished "unset HTTP_IF_MODIFIED_SINCE" &&
161 gitweb_run "p=.git;a=snapshot;h=master;sf=tgz" &&
162 grep "Status: 200 OK" gitweb.headers
164 test_debug 'cat gitweb.headers'
166 test_expect_success DATE_PARSER 'modification: snapshot if-modified-since (unmodified)' '
167 HTTP_IF_MODIFIED_SINCE="Thu, 7 Apr 2005 22:14:13 +0000" &&
168 export HTTP_IF_MODIFIED_SINCE &&
169 test_when_finished "unset HTTP_IF_MODIFIED_SINCE" &&
170 gitweb_run "p=.git;a=snapshot;h=master;sf=tgz" &&
171 grep "Status: 304 Not Modified" gitweb.headers
173 test_debug 'cat gitweb.headers'
175 test_expect_success DATE_PARSER 'modification: tree snapshot' '
176 ID=$(git rev-parse --verify HEAD^{tree}) &&
177 HTTP_IF_MODIFIED_SINCE="Wed, 6 Apr 2005 22:14:13 +0000" &&
178 export HTTP_IF_MODIFIED_SINCE &&
179 test_when_finished "unset HTTP_IF_MODIFIED_SINCE" &&
180 gitweb_run "p=.git;a=snapshot;h=$ID;sf=tgz" &&
181 grep "Status: 200 OK" gitweb.headers &&
182 ! grep -i "last-modified" gitweb.headers
184 test_debug 'cat gitweb.headers'
186 # ----------------------------------------------------------------------
187 # load checking
189 # always hit the load limit
190 cat >>gitweb_config.perl <<\EOF
191 our $maxload = -1;
194 test_expect_success 'load checking: load too high (default action)' '
195 gitweb_run "p=.git" &&
196 grep "Status: 503 Service Unavailable" gitweb.headers &&
197 grep "503 - The load average on the server is too high" gitweb.body
199 test_debug 'cat gitweb.headers'
201 # turn off load checking
202 cat >>gitweb_config.perl <<\EOF
203 our $maxload = undef;
207 # ----------------------------------------------------------------------
208 # invalid arguments
210 test_expect_success 'invalid arguments: invalid regexp (in project search)' '
211 gitweb_run "a=project_list;s=*\.git;sr=1" &&
212 grep "Status: 400" gitweb.headers &&
213 grep "400 - Invalid.*regexp" gitweb.body
215 test_debug 'cat gitweb.headers'
217 test_done