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
15 # ----------------------------------------------------------------------
22 cat >>gitweb_config.perl <<\EOF
23 $feature{'snapshot'}{'override'} = 0;
27 'snapshots: tgz only default format enabled' \
28 'gitweb_run "p=.git;a=snapshot;h=HEAD;sf=tgz" &&
29 grep "Status: 200 OK" gitweb.output &&
30 gitweb_run "p=.git;a=snapshot;h=HEAD;sf=tbz2" &&
31 grep "403 - Unsupported snapshot format" gitweb.output &&
32 gitweb_run "p=.git;a=snapshot;h=HEAD;sf=txz" &&
33 grep "403 - Snapshot format not allowed" gitweb.output &&
34 gitweb_run "p=.git;a=snapshot;h=HEAD;sf=zip" &&
35 grep "403 - Unsupported snapshot format" gitweb.output'
38 cat >>gitweb_config.perl <<\EOF
39 $feature{'snapshot'}{'default'} = ['tgz','tbz2','txz','zip'];
43 'snapshots: all enabled in default, use default disabled value' \
44 'gitweb_run "p=.git;a=snapshot;h=HEAD;sf=tgz" &&
45 grep "Status: 200 OK" gitweb.output &&
46 gitweb_run "p=.git;a=snapshot;h=HEAD;sf=tbz2" &&
47 grep "Status: 200 OK" gitweb.output &&
48 gitweb_run "p=.git;a=snapshot;h=HEAD;sf=txz" &&
49 grep "403 - Snapshot format not allowed" gitweb.output &&
50 gitweb_run "p=.git;a=snapshot;h=HEAD;sf=zip" &&
51 grep "Status: 200 OK" gitweb.output'
54 cat >>gitweb_config.perl <<\EOF
55 $known_snapshot_formats{'zip'}{'disabled'} = 1;
59 'snapshots: zip explicitly disabled' \
60 'gitweb_run "p=.git;a=snapshot;h=HEAD;sf=zip" &&
61 grep "403 - Snapshot format not allowed" gitweb.output'
62 test_debug 'cat gitweb.output'
65 cat >>gitweb_config.perl <<\EOF
66 $known_snapshot_formats{'tgz'}{'disabled'} = 0;
70 'snapshots: tgz explicitly enabled' \
71 'gitweb_run "p=.git;a=snapshot;h=HEAD;sf=tgz" &&
72 grep "Status: 200 OK" gitweb.output'
73 test_debug 'cat gitweb.headers'
76 # ----------------------------------------------------------------------
79 test_expect_success 'snapshots: good tree-ish id' '
80 gitweb_run "p=.git;a=snapshot;h=master;sf=tgz" &&
81 grep "Status: 200 OK" gitweb.output
83 test_debug 'cat gitweb.headers'
85 test_expect_success 'snapshots: bad tree-ish id' '
86 gitweb_run "p=.git;a=snapshot;h=frizzumFrazzum;sf=tgz" &&
87 grep "404 - Object does not exist" gitweb.output
89 test_debug 'cat gitweb.output'
91 test_expect_success 'snapshots: bad tree-ish id (tagged object)' '
92 echo object > tag-object &&
94 git commit -m "Object to be tagged" &&
95 git tag tagged-object `git hash-object tag-object` &&
96 gitweb_run "p=.git;a=snapshot;h=tagged-object;sf=tgz" &&
97 grep "400 - Object is not a tree-ish" gitweb.output
99 test_debug 'cat gitweb.output'
101 test_expect_success 'snapshots: good object id' '
102 ID=`git rev-parse --verify HEAD` &&
103 gitweb_run "p=.git;a=snapshot;h=$ID;sf=tgz" &&
104 grep "Status: 200 OK" gitweb.output
106 test_debug 'cat gitweb.headers'
108 test_expect_success 'snapshots: bad object id' '
109 gitweb_run "p=.git;a=snapshot;h=abcdef01234;sf=tgz" &&
110 grep "404 - Object does not exist" gitweb.output
112 test_debug 'cat gitweb.output'
115 # ----------------------------------------------------------------------
118 # always hit the load limit
119 cat >>gitweb_config.perl <<\EOF
123 test_expect_success 'load checking: load too high (default action)' '
124 gitweb_run "p=.git" &&
125 grep "Status: 503 Service Unavailable" gitweb.headers &&
126 grep "503 - The load average on the server is too high" gitweb.body
128 test_debug 'cat gitweb.log' # just in case
129 test_debug 'cat gitweb.headers'
131 # turn off load checking
132 cat >>gitweb_config.perl <<\EOF
133 our $maxload = undef;