Skip to content

Commit

Permalink
Add actual IPv4 tests for #314 and fix indentation + Flake8.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Howitz committed Nov 9, 2018
1 parent 7d89d13 commit 2abb838
Showing 1 changed file with 30 additions and 21 deletions.
51 changes: 30 additions & 21 deletions src/Products/SiteAccess/tests/testVirtualHostMonster.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,41 +170,50 @@ def tearDown(self):
transaction.abort()
self.app._p_jar.close()

def testHostname(self):
self.traverse('/VirtualHostBase/http/www.mysite.com:80/folder/')
self.assertEqual(self.app.REQUEST['ACTUAL_URL'],
'http://www.mysite.com/folder/')

def testHostnameNoport(self):
self.traverse('/VirtualHostBase/http/www.mysite.com/folder/')
self.assertEqual(self.app.REQUEST['ACTUAL_URL'],
'http://www.mysite.com/folder/')

def testPassedPortHostname(self):
self.traverse('/VirtualHostBase/http/www.mysite.com:81/folder/')
self.assertEqual(self.app.REQUEST['ACTUAL_URL'],
'http://www.mysite.com:81/folder/')

def testIPv4(self):
ob = self.traverse('/VirtualHostBase/http/www.mysite.com:80'
'/folder/')
self.assertEqual(self.app.REQUEST['ACTUAL_URL'],
'http://www.mysite.com/folder/')
self.traverse('/VirtualHostBase/http/127.0.0.1:80/folder/')
self.assertEqual(self.app.REQUEST['ACTUAL_URL'],
'http://127.0.0.1/folder/')

def testIPv4Noport(self):
ob = self.traverse('/VirtualHostBase/http/www.mysite.com'
'/folder/')
self.assertEqual(self.app.REQUEST['ACTUAL_URL'],
'http://www.mysite.com/folder/')
self.traverse('/VirtualHostBase/http/127.0.0.1/folder/')
self.assertEqual(self.app.REQUEST['ACTUAL_URL'],
'http://127.0.0.1/folder/')

def testPassedPortIPv4(self):
ob = self.traverse('/VirtualHostBase/http/www.mysite.com:81'
'/folder/')
self.assertEqual(self.app.REQUEST['ACTUAL_URL'],
'http://www.mysite.com:81/folder/')
self.traverse('/VirtualHostBase/http/127.0.0.1:81/folder/')
self.assertEqual(self.app.REQUEST['ACTUAL_URL'],
'http://127.0.0.1:81/folder/')

def testIPv6(self):
ob = self.traverse('/VirtualHostBase/http/[::1]:80'
'/folder/')
self.traverse('/VirtualHostBase/http/[::1]:80/folder/')
self.assertEqual(self.app.REQUEST['ACTUAL_URL'],
'http://[::1]/folder/')
'http://[::1]/folder/')

def testIPv6NoPort(self):
ob = self.traverse('/VirtualHostBase/http/[::1]'
'/folder/')
self.traverse('/VirtualHostBase/http/[::1]/folder/')
self.assertEqual(self.app.REQUEST['ACTUAL_URL'],
'http://[::1]/folder/')
'http://[::1]/folder/')

def testIPv6PassedPort(self):
ob = self.traverse('/VirtualHostBase/http/[::1]:81'
'/folder/')
self.traverse('/VirtualHostBase/http/[::1]:81/folder/')
self.assertEqual(self.app.REQUEST['ACTUAL_URL'],
'http://[::1]:81/folder/')
'http://[::1]:81/folder/')


class VHMAddingTests(unittest.TestCase):
Expand Down

0 comments on commit 2abb838

Please sign in to comment.