Skip to content
This repository
Newer
Older
100644 46 lines (34 sloc) 1.177 kb
860827a6 »
2009-11-19 Adds X-Real-IP header support to all the FastCGI, SCGI, uWSGI, and CGI
1 from base import *
2
3 DIR = "x_real_ip_cgi_1"
4 REMOTE_IP = "1.2.3.4"
5
6 CONF = """
7 vserver!1!rule!2320!match = directory
8 vserver!1!rule!2320!match!directory = /%s
9 vserver!1!rule!2320!handler = cgi
10 vserver!1!rule!2320!handler!x_real_ip_enabled = 1
11 vserver!1!rule!2320!handler!x_real_ip_access_all = 0
12 vserver!1!rule!2320!handler!x_real_ip_access = ::1,127.0.0.1
13 """ % (DIR)
14
15 CGI_CODE = """#!/bin/sh
16
17 echo "Content-Type: text/plain"
72f64441 »
2009-12-13 Clean up: Trims trailing spaces.
18 echo
860827a6 »
2009-11-19 Adds X-Real-IP header support to all the FastCGI, SCGI, uWSGI, and CGI
19
20 echo "REMOTE_ADDR ->${REMOTE_ADDR}<-"
21 echo
22 """
23
24 class Test (TestBase):
25 def __init__ (self):
26 TestBase.__init__ (self, __file__)
27 self.name = "X-Real-IP to REMOTE_ADDR: CGI"
28
29 self.request = "GET /%s/test HTTP/1.0\r\n" % (DIR) + \
30 "X-Real-IP: %s\r\n" % (REMOTE_IP)
31 self.expected_error = 200
32 self.conf = CONF
cbafd4fa »
2009-11-27 These three QA tests cannot be run through a proxy server.
33 self.proxy_suitable = False
860827a6 »
2009-11-19 Adds X-Real-IP header support to all the FastCGI, SCGI, uWSGI, and CGI
34
35 def CustomTest (self):
36 body = self.reply.split ("\r\n\r\n")[1]
37
38 if "REMOTE_ADDR ->%s<-" %(REMOTE_IP) in body:
39 return 0
40
41 return -1
42
43 def Prepare (self, www):
44 d = self.Mkdir (www, DIR, 0777)
45 self.WriteFile (d, "test", 0555, CGI_CODE)
Something went wrong with that request. Please try again.