Uploaded image for project: 'mod_python'
  1. mod_python
  2. MODPYTHON-121

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

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.2.7
    • Fix Version/s: 3.3.1
    • Component/s: None
    • Labels:
      None

      Description

      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 {}")

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            grahamd Graham Dumpleton
            Reporter:
            grahamd Graham Dumpleton
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development