gitweb: add t9501 tests for checking HTTP status codes
Adds a new test file, t9501, that checks HTTP status codes and messages from gitweb. Currently, the only tests are for the snapshot feature. Signed-off-by: Mark Rada <marada@uwaterloo.ca> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Mark Rada committed
Aug 25, 2009 at 01:03 UTC
e39e0d375d1d84fc1fff14b58c729fbd289cdd01
1 file changed
+78
t/t9501-gitweb-standalone-http-status.sh
new
+78
@@ -0,0 +1,78 @@
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
+
18
+test_commit \
19
+ 'SnapshotTests' \
20
+ 'i can has snapshot?'
21
+
22
+cat >>gitweb_config.perl <<\EOF
23
+$feature{'snapshot'}{'override'} = 0;
24
+EOF
25
+
26
+test_expect_success \
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'
36
+test_debug 'cat gitweb.output'
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'
53
+test_debug 'cat gitweb.output'
54
+
55
+
56
+cat >>gitweb_config.perl <<\EOF
57
+$known_snapshot_formats{'zip'}{'disabled'} = 1;
58
+EOF
59
+
60
+test_expect_success \
61
+ 'snapshots: zip explicitly disabled' \
62
+ 'gitweb_run "p=.git;a=snapshot;h=HEAD;sf=zip" &&
63
+ grep "403 - Snapshot format not allowed" gitweb.output'
64
+test_debug 'cat gitweb.output'
65
+
66
+
67
+cat >>gitweb_config.perl <<\EOF
68
+$known_snapshot_formats{'tgz'}{'disabled'} = 0;
69
+EOF
70
+
71
+test_expect_success \
72
+ 'snapshots: tgz explicitly enabled' \
73
+ 'gitweb_run "p=.git;a=snapshot;h=HEAD;sf=tgz" &&
74
+ grep "Status: 200 OK" gitweb.output'
75
+test_debug 'cat gitweb.output'
76
+
77
+
78
+test_done