Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
b7046ffb
Commit
b7046ffb
authored
Nov 09, 2018
by
Jérome Perrin
Committed by
GitHub
Nov 09, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #395 from perrinjerome/backport/314
Zope 2.13: SiteAccess: Make VirtualHostMonster support IPv6
parents
0c4b5d6c
6fbaee13
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
11 deletions
+72
-11
src/Products/SiteAccess/VirtualHostMonster.py
src/Products/SiteAccess/VirtualHostMonster.py
+2
-5
src/Products/SiteAccess/tests/testVirtualHostMonster.py
src/Products/SiteAccess/tests/testVirtualHostMonster.py
+70
-6
No files found.
src/Products/SiteAccess/VirtualHostMonster.py
View file @
b7046ffb
...
...
@@ -15,6 +15,7 @@ from ZPublisher.BeforeTraverse import queryBeforeTraverse
from
ZPublisher.BeforeTraverse
import
registerBeforeTraverse
from
ZPublisher.BeforeTraverse
import
unregisterBeforeTraverse
from
ZPublisher.BaseRequest
import
quote
from
ZPublisher.HTTPRequest
import
splitport
from
zExceptions
import
BadRequest
class
VirtualHostMonster
(
Persistent
,
Item
,
Implicit
):
...
...
@@ -150,11 +151,7 @@ class VirtualHostMonster(Persistent, Item, Implicit):
stack
.
pop
()
protocol
=
stack
.
pop
()
host
=
stack
.
pop
()
if
':'
in
host
:
host
,
port
=
host
.
split
(
':'
)
request
.
setServerURL
(
protocol
,
host
,
port
)
else
:
request
.
setServerURL
(
protocol
,
host
)
request
.
setServerURL
(
protocol
,
*
splitport
(
host
))
path
=
list
(
stack
)
# Find and convert VirtualHostRoot directive
...
...
src/Products/SiteAccess/tests/testVirtualHostMonster.py
View file @
b7046ffb
...
...
@@ -97,7 +97,7 @@ class VHMRegressions(unittest.TestCase):
ob
=
self
.
traverse
(
'/VirtualHostBase/http/www.mysite.com:80'
'/folder/VirtualHostRoot'
)
self
.
assertEqual
(
self
.
app
.
REQUEST
[
'ACTUAL_URL'
],
'http://www.mysite.com/'
)
'http://www.mysite.com/'
)
def
gen_cases
():
for
vbase
,
ubase
in
(
...
...
@@ -139,6 +139,75 @@ for i, (vaddr, vr, _vh, p, ubase) in enumerate(gen_cases()):
setattr
(
VHMRegressions
,
'testTraverse%s'
%
i
,
test
)
class
VHMPort
(
unittest
.
TestCase
):
def
setUp
(
self
):
import
transaction
from
Testing.makerequest
import
makerequest
from
Testing.ZopeTestCase.ZopeLite
import
app
transaction
.
begin
()
self
.
app
=
makerequest
(
app
())
if
'virtual_hosting'
not
in
self
.
app
.
objectIds
():
# If ZopeLite was imported, we have no default virtual
# host monster
from
Products.SiteAccess.VirtualHostMonster
\
import
manage_addVirtualHostMonster
manage_addVirtualHostMonster
(
self
.
app
,
'virtual_hosting'
)
self
.
app
.
manage_addFolder
(
'folder'
)
self
.
app
.
folder
.
manage_addDTMLMethod
(
'doc'
,
''
)
self
.
app
.
REQUEST
.
set
(
'PARENTS'
,
[
self
.
app
])
self
.
traverse
=
self
.
app
.
REQUEST
.
traverse
def
tearDown
(
self
):
import
transaction
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
):
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
):
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
):
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
):
self
.
traverse
(
'/VirtualHostBase/http/[::1]:80/folder/'
)
self
.
assertEqual
(
self
.
app
.
REQUEST
[
'ACTUAL_URL'
],
'http://[::1]/folder/'
)
def
testIPv6NoPort
(
self
):
self
.
traverse
(
'/VirtualHostBase/http/[::1]/folder/'
)
self
.
assertEqual
(
self
.
app
.
REQUEST
[
'ACTUAL_URL'
],
'http://[::1]/folder/'
)
def
testIPv6PassedPort
(
self
):
self
.
traverse
(
'/VirtualHostBase/http/[::1]:81/folder/'
)
self
.
assertEqual
(
self
.
app
.
REQUEST
[
'ACTUAL_URL'
],
'http://[::1]:81/folder/'
)
class
VHMAddingTests
(
unittest
.
TestCase
):
...
...
@@ -198,8 +267,3 @@ class VHMAddingTests(unittest.TestCase):
hook
=
queryBeforeTraverse
(
self
.
root
,
VirtualHostMonster
.
meta_type
)
self
.
assertTrue
(
hook
)
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
VHMRegressions
))
suite
.
addTest
(
unittest
.
makeSuite
(
VHMAddingTests
))
return
suite
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment