Switched to use `HTTP_X_FORWARDED_PROTO` custom header in tests.
This is the conventional name: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Proto
This commit is contained in:
parent
f7e9db14bb
commit
d7673d9eda
|
@ -361,24 +361,24 @@ class SecureProxySslHeaderTest(SimpleTestCase):
|
||||||
req = HttpRequest()
|
req = HttpRequest()
|
||||||
self.assertIs(req.is_secure(), False)
|
self.assertIs(req.is_secure(), False)
|
||||||
|
|
||||||
@override_settings(SECURE_PROXY_SSL_HEADER=('HTTP_X_FORWARDED_PROTOCOL', 'https'))
|
@override_settings(SECURE_PROXY_SSL_HEADER=('HTTP_X_FORWARDED_PROTO', 'https'))
|
||||||
def test_set_without_xheader(self):
|
def test_set_without_xheader(self):
|
||||||
req = HttpRequest()
|
req = HttpRequest()
|
||||||
self.assertIs(req.is_secure(), False)
|
self.assertIs(req.is_secure(), False)
|
||||||
|
|
||||||
@override_settings(SECURE_PROXY_SSL_HEADER=('HTTP_X_FORWARDED_PROTOCOL', 'https'))
|
@override_settings(SECURE_PROXY_SSL_HEADER=('HTTP_X_FORWARDED_PROTO', 'https'))
|
||||||
def test_set_with_xheader_wrong(self):
|
def test_set_with_xheader_wrong(self):
|
||||||
req = HttpRequest()
|
req = HttpRequest()
|
||||||
req.META['HTTP_X_FORWARDED_PROTOCOL'] = 'wrongvalue'
|
req.META['HTTP_X_FORWARDED_PROTO'] = 'wrongvalue'
|
||||||
self.assertIs(req.is_secure(), False)
|
self.assertIs(req.is_secure(), False)
|
||||||
|
|
||||||
@override_settings(SECURE_PROXY_SSL_HEADER=('HTTP_X_FORWARDED_PROTOCOL', 'https'))
|
@override_settings(SECURE_PROXY_SSL_HEADER=('HTTP_X_FORWARDED_PROTO', 'https'))
|
||||||
def test_set_with_xheader_right(self):
|
def test_set_with_xheader_right(self):
|
||||||
req = HttpRequest()
|
req = HttpRequest()
|
||||||
req.META['HTTP_X_FORWARDED_PROTOCOL'] = 'https'
|
req.META['HTTP_X_FORWARDED_PROTO'] = 'https'
|
||||||
self.assertIs(req.is_secure(), True)
|
self.assertIs(req.is_secure(), True)
|
||||||
|
|
||||||
@override_settings(SECURE_PROXY_SSL_HEADER=('HTTP_X_FORWARDED_PROTOCOL', 'https'))
|
@override_settings(SECURE_PROXY_SSL_HEADER=('HTTP_X_FORWARDED_PROTO', 'https'))
|
||||||
def test_xheader_preferred_to_underlying_request(self):
|
def test_xheader_preferred_to_underlying_request(self):
|
||||||
class ProxyRequest(HttpRequest):
|
class ProxyRequest(HttpRequest):
|
||||||
def _get_scheme(self):
|
def _get_scheme(self):
|
||||||
|
@ -387,7 +387,7 @@ class SecureProxySslHeaderTest(SimpleTestCase):
|
||||||
|
|
||||||
# Client connects via HTTP.
|
# Client connects via HTTP.
|
||||||
req = ProxyRequest()
|
req = ProxyRequest()
|
||||||
req.META['HTTP_X_FORWARDED_PROTOCOL'] = 'http'
|
req.META['HTTP_X_FORWARDED_PROTO'] = 'http'
|
||||||
self.assertIs(req.is_secure(), False)
|
self.assertIs(req.is_secure(), False)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue