Issue Details (XML | Word | Printable)

Key: MODPYTHON-120
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Graham Dumpleton
Reporter: Graham Dumpleton
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
mod_python

Connection handler test fails on virtual hosting system such as OpenVPS.

Created: 05/Feb/06 07:53 AM   Updated: 05/Apr/07 11:40 AM
Component/s: core
Affects Version/s: 3.2.7
Fix Version/s: 3.3.1

Time Tracking:
Not Specified

Resolution Date: 02/Apr/06 04:54 PM
Labels:


 Description  « Hide
On a virtual hosting environment such as OpenVPS, "localhost" does not map to the IP address "127.0.0.1" but the actual IP of the host.

  >>> import socket
  >>> socket.gethostbyname("localhost")
  '207.126.122.36'

This fact causes the connection handler test to fail because it sets up the virtual host listener definition as something like:

  Listen 59180
  <VirtualHost 127.0.0.1:59180>
    SetHandler mod_python
    PythonPath [r'/home/grahamd/mod_python-3.2.7/test/htdocs']+sys.path
    PythonConnectionHandler tests::connectionhandler
  </VirtualHost>

In this case it really needs to be:

  Listen 59180
  <VirtualHost 207.126.122.36:59180>
    SetHandler mod_python
    PythonPath [r'/home/grahamd/mod_python-3.2.7/test/htdocs']+sys.path
    PythonConnectionHandler tests::connectionhandler
  </VirtualHost>

To accomodate virtual hosting arrangements, the test might be able to be rewritten as:

    def test_connectionhandler_conf(self):

        try:
            ip = socket.gethostbyname("localhost")
        except:
            ip = "127.0.0.1"

        self.conport = findUnusedPort()
        c = str(Listen("%d" % self.conport)) + \
            str(VirtualHost("%s:%d" % (ip,self.conport),
                            SetHandler("mod_python"),
                            PythonPath("[r'%s']+sys.path" % DOCUMENT_ROOT),
                            PythonConnectionHandler("tests::connectionhandler")))
        return c

This should always work on UNIX boxes, but whether it does on Win32 boxes would need to be confirmed.

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Repository Revision Date User Message
ASF #390778 Sun Apr 02 05:13:22 UTC 2006 grahamd Fixes to test suite so it will work on virtual hosting environments
where localhost doesn't resolve to 127.0.0.1 but the actual IP address
of the host. (MODPYTHON-120) (MODPYTHON-121)
Files Changed
MODIFY /httpd/mod_python/trunk/test/htdocs/tests.py
MODIFY /httpd/mod_python/trunk/test/test.py
MODIFY /httpd/mod_python/trunk/Doc/appendixc.tex

Graham Dumpleton made changes - 02/Apr/06 01:11 PM
Field Original Value New Value
Assignee Graham Dumpleton [ grahamd ]
Graham Dumpleton made changes - 02/Apr/06 01:11 PM
Status Open [ 1 ] In Progress [ 3 ]
Graham Dumpleton made changes - 02/Apr/06 04:54 PM
Status In Progress [ 3 ] Resolved [ 5 ]
Fix Version/s 3.3 [ 12310101 ]
Resolution Fixed [ 1 ]
Graham Dumpleton made changes - 05/Apr/07 11:40 AM
Status Resolved [ 5 ] Closed [ 6 ]