Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

request.host_port is a str not an int #2512

Merged
merged 1 commit into from
Apr 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyramid/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def _fail(reason):
"pyramid.csrf_trusted_origins", [])
)

if request.host_port not in set([80, 443]):
if request.host_port not in set(["80", "443"]):
trusted_origins.append("{0.domain}:{0.host_port}".format(request))
else:
trusted_origins.append(request.domain)
Expand Down
14 changes: 7 additions & 7 deletions pyramid/tests/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ def test_success_with_https_and_referrer(self):
request = testing.DummyRequest()
request.scheme = "https"
request.host = "example.com"
request.host_port = 443
request.host_port = "443"
request.referrer = "https://example.com/login/"
request.registry.settings = {}
self.assertTrue(self._callFUT(request))
Expand All @@ -730,7 +730,7 @@ def test_success_with_https_and_origin(self):
request = testing.DummyRequest()
request.scheme = "https"
request.host = "example.com"
request.host_port = 443
request.host_port = "443"
request.headers = {"Origin": "https://example.com/"}
request.referrer = "https://not-example.com/"
request.registry.settings = {}
Expand All @@ -740,7 +740,7 @@ def test_success_with_additional_trusted_host(self):
request = testing.DummyRequest()
request.scheme = "https"
request.host = "example.com"
request.host_port = 443
request.host_port = "443"
request.referrer = "https://not-example.com/login/"
request.registry.settings = {
"pyramid.csrf_trusted_origins": ["not-example.com"],
Expand All @@ -751,7 +751,7 @@ def test_success_with_nonstandard_port(self):
request = testing.DummyRequest()
request.scheme = "https"
request.host = "example.com:8080"
request.host_port = 8080
request.host_port = "8080"
request.referrer = "https://example.com:8080/login/"
request.registry.settings = {}
self.assertTrue(self._callFUT(request))
Expand All @@ -761,7 +761,7 @@ def test_fails_with_wrong_host(self):
request = testing.DummyRequest()
request.scheme = "https"
request.host = "example.com"
request.host_port = 443
request.host_port = "443"
request.referrer = "https://not-example.com/login/"
request.registry.settings = {}
self.assertRaises(BadCSRFOrigin, self._callFUT, request)
Expand All @@ -780,7 +780,7 @@ def test_fails_when_http_to_https(self):
request = testing.DummyRequest()
request.scheme = "https"
request.host = "example.com"
request.host_port = 443
request.host_port = "443"
request.referrer = "http://example.com/evil/"
request.registry.settings = {}
self.assertRaises(BadCSRFOrigin, self._callFUT, request)
Expand All @@ -791,7 +791,7 @@ def test_fails_with_nonstandard_port(self):
request = testing.DummyRequest()
request.scheme = "https"
request.host = "example.com:8080"
request.host_port = 8080
request.host_port = "8080"
request.referrer = "https://example.com/login/"
request.registry.settings = {}
self.assertRaises(BadCSRFOrigin, self._callFUT, request)
Expand Down
6 changes: 3 additions & 3 deletions pyramid/tests/test_viewderivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1148,7 +1148,7 @@ def inner_view(request):
request = self._makeRequest()
request.scheme = "https"
request.domain = "example.com"
request.host_port = 443
request.host_port = "443"
request.referrer = "https://example.com/login/"
request.method = 'POST'
request.session = DummySession({'csrf_token': 'foo'})
Expand Down Expand Up @@ -1208,7 +1208,7 @@ def inner_view(request): pass
request = self._makeRequest()
request.method = "POST"
request.scheme = "https"
request.host_port = 443
request.host_port = "443"
request.domain = "example.com"
request.referrer = "https://not-example.com/evil/"
request.registry.settings = {}
Expand All @@ -1221,7 +1221,7 @@ def inner_view(request): pass
request = self._makeRequest()
request.method = "POST"
request.scheme = "https"
request.host_port = 443
request.host_port = "443"
request.domain = "example.com"
request.headers = {"Origin": "https://not-example.com/evil/"}
request.registry.settings = {}
Expand Down