Issue Details (XML | Word | Printable)

Key: MODPYTHON-121
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

The local/remote host tests fail for a virtual hosting system such as OpenVPS.

Created: 05/Feb/06 08:06 AM   Updated: 05/Apr/07 11:41 AM
Return to search
Component/s: None
Affects Version/s: 3.2.7
Fix Version/s: 3.3.1

Time Tracking:
Not Specified

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


 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 various aspects of the test_connection_members() test to fail. To avoid the problem the test could factor in the actual IP as returned for "localhost". Thus in htdocs/tests.py, could read as follows. This should be okay on UNIX systems, but should be confirmed as okay on Win32 systems.

    def test_connection_members(self):

        req = self.req
        log = req.log_error
        conn = req.connection

        log("Examining connection memebers:")

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

        log(" connection.base_server: %s" % `conn.base_server`)
        if type(conn.base_server) is not type(req.server):
            self.fail("conn.base_server should be same type as req.server")

        log(" connection.local_addr: %s" % `conn.local_addr`)
        if not conn.local_addr[0] in ("127.0.0.1", "0.0.0.0", ip):
            self.fail("conn.local_addr[0] should be '127.0.0.1' or '0.0.0.0'")

        log(" connection.remote_addr: %s" % `conn.remote_addr`)
        if not conn.remote_addr[0] in ("127.0.0.1", "0.0.0.0", ip):
            self.fail("conn.remote_addr[0] should be '127.0.0.1' or '0.0.0.0'")

        log(" connection.remote_ip: %s" % `conn.remote_ip`)
        if not conn.remote_ip in ("127.0.0.1", ip):
            self.fail("conn.remote_ip should be '127.0.0.1'")

        log(" connection.remote_host: %s" % `conn.remote_host`)
        if conn.remote_host is not None:
            self.fail("conn.remote_host should be None")

        log(" connection.remote_logname: %s" % `conn.remote_logname`)
        if conn.remote_logname is not None:
            self.fail("conn.remote_logname should be None")

        log(" connection.aborted: %s" % `conn.aborted`)
        if conn.aborted != 0:
            self.fail("conn.aborted should be 0")

        log(" connection.keepalive: %s" % `conn.keepalive`)
        if conn.keepalive != 2:
            self.fail("conn.keepalive should be 2")

        log(" connection.double_reverse: %s" % `conn.double_reverse`)
        if conn.double_reverse != 0:
            self.fail("conn.double_reverse should be 0")

        log(" connection.keepalives: %s" % `conn.keepalives`)
        if conn.keepalives != 1:
            self.fail("conn.keepalives should be 1")

        log(" connection.local_ip: %s" % `conn.local_ip`)
        if not conn.local_ip in ("127.0.0.1", ip):
            self.fail("conn.local_ip should be '127.0.0.1'")

        log(" connection.local_host: %s" % `conn.local_host`)
        if conn.local_host is not None:
            self.fail("conn.local_host should be None")

        log(" connection.id: %s" % `conn.id`)
        if conn.id > 100:
            self.fail("conn.id should not be this high")

        log(" connection.notes: %s" % `conn.notes`)
        if `conn.notes` != '{}':
            self.fail("conn.notes should be {}")


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Graham Dumpleton made changes - 02/Apr/06 01:10 PM
Field Original Value New Value
Assignee Graham Dumpleton [ grahamd ]
Graham Dumpleton made changes - 02/Apr/06 01:10 PM
Status Open [ 1 ] In Progress [ 3 ]
Graham Dumpleton made changes - 02/Apr/06 04:54 PM
Fix Version/s 3.3 [ 12310101 ]
Status In Progress [ 3 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]
Graham Dumpleton made changes - 05/Apr/07 11:41 AM
Status Resolved [ 5 ] Closed [ 6 ]