Mark Rada | e39e0d3 | 2009-08-25 01:03:48 -0400 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Copyright (c) 2009 Mark Rada |
| 4 | # |
| 5 | |
| 6 | test_description='gitweb as standalone script (http status tests). |
| 7 | |
| 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.' |
| 11 | |
| 12 | |
| 13 | . ./gitweb-lib.sh |
| 14 | |
| 15 | # ---------------------------------------------------------------------- |
| 16 | # snapshot settings |
| 17 | |
Brian Gernhardt | 4a45f7d | 2010-03-20 04:29:11 -0400 | [diff] [blame] | 18 | test_expect_success 'setup' " |
| 19 | test_commit 'SnapshotTests' 'i can has snapshot?' |
| 20 | " |
| 21 | |
Mark Rada | e39e0d3 | 2009-08-25 01:03:48 -0400 | [diff] [blame] | 22 | |
| 23 | cat >>gitweb_config.perl <<\EOF |
| 24 | $feature{'snapshot'}{'override'} = 0; |
| 25 | EOF |
| 26 | |
| 27 | test_expect_success \ |
| 28 | 'snapshots: tgz only default format enabled' \ |
| 29 | 'gitweb_run "p=.git;a=snapshot;h=HEAD;sf=tgz" && |
| 30 | grep "Status: 200 OK" gitweb.output && |
| 31 | gitweb_run "p=.git;a=snapshot;h=HEAD;sf=tbz2" && |
| 32 | grep "403 - Unsupported snapshot format" gitweb.output && |
| 33 | gitweb_run "p=.git;a=snapshot;h=HEAD;sf=txz" && |
| 34 | grep "403 - Snapshot format not allowed" gitweb.output && |
| 35 | gitweb_run "p=.git;a=snapshot;h=HEAD;sf=zip" && |
| 36 | grep "403 - Unsupported snapshot format" gitweb.output' |
Mark Rada | e39e0d3 | 2009-08-25 01:03:48 -0400 | [diff] [blame] | 37 | |
| 38 | |
| 39 | cat >>gitweb_config.perl <<\EOF |
| 40 | $feature{'snapshot'}{'default'} = ['tgz','tbz2','txz','zip']; |
| 41 | EOF |
| 42 | |
| 43 | test_expect_success \ |
| 44 | 'snapshots: all enabled in default, use default disabled value' \ |
| 45 | 'gitweb_run "p=.git;a=snapshot;h=HEAD;sf=tgz" && |
| 46 | grep "Status: 200 OK" gitweb.output && |
| 47 | gitweb_run "p=.git;a=snapshot;h=HEAD;sf=tbz2" && |
| 48 | grep "Status: 200 OK" gitweb.output && |
| 49 | gitweb_run "p=.git;a=snapshot;h=HEAD;sf=txz" && |
| 50 | grep "403 - Snapshot format not allowed" gitweb.output && |
| 51 | gitweb_run "p=.git;a=snapshot;h=HEAD;sf=zip" && |
| 52 | grep "Status: 200 OK" gitweb.output' |
Mark Rada | e39e0d3 | 2009-08-25 01:03:48 -0400 | [diff] [blame] | 53 | |
| 54 | |
| 55 | cat >>gitweb_config.perl <<\EOF |
| 56 | $known_snapshot_formats{'zip'}{'disabled'} = 1; |
| 57 | EOF |
| 58 | |
| 59 | test_expect_success \ |
| 60 | 'snapshots: zip explicitly disabled' \ |
| 61 | 'gitweb_run "p=.git;a=snapshot;h=HEAD;sf=zip" && |
| 62 | grep "403 - Snapshot format not allowed" gitweb.output' |
| 63 | test_debug 'cat gitweb.output' |
| 64 | |
| 65 | |
| 66 | cat >>gitweb_config.perl <<\EOF |
| 67 | $known_snapshot_formats{'tgz'}{'disabled'} = 0; |
| 68 | EOF |
| 69 | |
| 70 | test_expect_success \ |
| 71 | 'snapshots: tgz explicitly enabled' \ |
| 72 | 'gitweb_run "p=.git;a=snapshot;h=HEAD;sf=tgz" && |
| 73 | grep "Status: 200 OK" gitweb.output' |
Jakub Narebski | 745a2db | 2010-01-30 23:30:38 +0100 | [diff] [blame] | 74 | test_debug 'cat gitweb.headers' |
Mark Rada | e39e0d3 | 2009-08-25 01:03:48 -0400 | [diff] [blame] | 75 | |
| 76 | |
Mark Rada | fdb0c36 | 2009-09-26 13:46:08 -0400 | [diff] [blame] | 77 | # ---------------------------------------------------------------------- |
| 78 | # snapshot hash ids |
| 79 | |
| 80 | test_expect_success 'snapshots: good tree-ish id' ' |
| 81 | gitweb_run "p=.git;a=snapshot;h=master;sf=tgz" && |
| 82 | grep "Status: 200 OK" gitweb.output |
| 83 | ' |
Jakub Narebski | 745a2db | 2010-01-30 23:30:38 +0100 | [diff] [blame] | 84 | test_debug 'cat gitweb.headers' |
Mark Rada | fdb0c36 | 2009-09-26 13:46:08 -0400 | [diff] [blame] | 85 | |
| 86 | test_expect_success 'snapshots: bad tree-ish id' ' |
| 87 | gitweb_run "p=.git;a=snapshot;h=frizzumFrazzum;sf=tgz" && |
| 88 | grep "404 - Object does not exist" gitweb.output |
| 89 | ' |
| 90 | test_debug 'cat gitweb.output' |
| 91 | |
| 92 | test_expect_success 'snapshots: bad tree-ish id (tagged object)' ' |
| 93 | echo object > tag-object && |
| 94 | git add tag-object && |
| 95 | git commit -m "Object to be tagged" && |
| 96 | git tag tagged-object `git hash-object tag-object` && |
| 97 | gitweb_run "p=.git;a=snapshot;h=tagged-object;sf=tgz" && |
| 98 | grep "400 - Object is not a tree-ish" gitweb.output |
| 99 | ' |
| 100 | test_debug 'cat gitweb.output' |
| 101 | |
| 102 | test_expect_success 'snapshots: good object id' ' |
| 103 | ID=`git rev-parse --verify HEAD` && |
| 104 | gitweb_run "p=.git;a=snapshot;h=$ID;sf=tgz" && |
| 105 | grep "Status: 200 OK" gitweb.output |
| 106 | ' |
Jakub Narebski | 745a2db | 2010-01-30 23:30:38 +0100 | [diff] [blame] | 107 | test_debug 'cat gitweb.headers' |
Mark Rada | fdb0c36 | 2009-09-26 13:46:08 -0400 | [diff] [blame] | 108 | |
| 109 | test_expect_success 'snapshots: bad object id' ' |
| 110 | gitweb_run "p=.git;a=snapshot;h=abcdef01234;sf=tgz" && |
| 111 | grep "404 - Object does not exist" gitweb.output |
| 112 | ' |
| 113 | test_debug 'cat gitweb.output' |
| 114 | |
| 115 | |
John 'Warthog9' Hawley | b62a1a9 | 2010-01-30 23:30:39 +0100 | [diff] [blame] | 116 | # ---------------------------------------------------------------------- |
| 117 | # load checking |
| 118 | |
| 119 | # always hit the load limit |
| 120 | cat >>gitweb_config.perl <<\EOF |
Brian Gernhardt | ab35469 | 2010-02-06 09:50:03 -0500 | [diff] [blame] | 121 | our $maxload = -1; |
John 'Warthog9' Hawley | b62a1a9 | 2010-01-30 23:30:39 +0100 | [diff] [blame] | 122 | EOF |
| 123 | |
Brian Gernhardt | ab35469 | 2010-02-06 09:50:03 -0500 | [diff] [blame] | 124 | test_expect_success 'load checking: load too high (default action)' ' |
John 'Warthog9' Hawley | b62a1a9 | 2010-01-30 23:30:39 +0100 | [diff] [blame] | 125 | gitweb_run "p=.git" && |
| 126 | grep "Status: 503 Service Unavailable" gitweb.headers && |
| 127 | grep "503 - The load average on the server is too high" gitweb.body |
| 128 | ' |
| 129 | test_debug 'cat gitweb.log' # just in case |
| 130 | test_debug 'cat gitweb.headers' |
| 131 | |
| 132 | # turn off load checking |
| 133 | cat >>gitweb_config.perl <<\EOF |
| 134 | our $maxload = undef; |
| 135 | EOF |
| 136 | |
| 137 | |
Mark Rada | e39e0d3 | 2009-08-25 01:03:48 -0400 | [diff] [blame] | 138 | test_done |