Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 64 lines (52 sloc) 1.832 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
from base import *

ERROR = 403
ERROR_MSG = """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Permission Denied - Cherokee Web Server</title>
</head>

<body>

<!-- Poem by Thomas Thurman <thomas@thurman.org.uk> -->

<h1>403 Access Denied</h1>

<p>So many years have passed since first you sought
the lands beyond the edges of the sky,
so many moons reflected in your eye,
(familiar newness, fear of leaving port),
since first you sought, and failed, and learned to fall,
(first hope, then cynicism, silent dread,
the countless stars, still counting overhead
the seconds to your final voyage of all...)
and last, in glory gold and red around
your greatest search, your final quest to know!
yet... ashes drift, the embers cease to glow,
and darkened life in frozen death is drowned;
and ashes on the swell are seen no more.
The silence surges.

<p><b>Error 403</b>.
</body>
</html>"""

CONF = """
vserver!1!rule!1120!match = directory
vserver!1!rule!1120!match!directory = /cgi_error_403_1
vserver!1!rule!1120!handler = cgi
vserver!1!rule!1120!handler!error_handler = 1
"""

CGI_BASE = """#!/bin/sh
echo "Content-type: text/html"
echo "Status: %s"
echo ""
cat << EOF
%s
EOF
"""

class Test (TestBase):
    def __init__ (self):
        TestBase.__init__ (self, __file__)
        self.name = "CGI error message"

        self.request = "GET /cgi_error_403_1/exec.cgi HTTP/1.0\r\n"
        self.expected_error = ERROR
        self.expected_content = ERROR_MSG
        self.conf = CONF

    def Prepare (self, www):
        d = self.Mkdir (www, "cgi_error_403_1")
        f = self.WriteFile (d, "exec.cgi", 0555, CGI_BASE % (ERROR, ERROR_MSG))
Something went wrong with that request. Please try again.