summaryrefslogtreecommitdiff
path: root/tests/settings_tests
diff options
context:
space:
mode:
authorThomas Schmidt <thomas@useobject.com>2022-03-07 17:25:52 -0500
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-03-23 19:33:36 +0100
commit1cf60ce6017d904024ee132f7edae0b4b821a954 (patch)
treebb73a5fcca79e812f2c7182ddf68dadee7c49ea2 /tests/settings_tests
parentd46e158ee21cb067a65d44699e6dce00b3dab8e3 (diff)
Fixed #33569 -- Added SECURE_PROXY_SSL_HEADER support for list of protocols in the header value.
Diffstat (limited to 'tests/settings_tests')
-rw-r--r--tests/settings_tests/tests.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/settings_tests/tests.py b/tests/settings_tests/tests.py
index 1b095533b1..f9ea7700bb 100644
--- a/tests/settings_tests/tests.py
+++ b/tests/settings_tests/tests.py
@@ -425,6 +425,26 @@ class SecureProxySslHeaderTest(SimpleTestCase):
self.assertIs(req.is_secure(), True)
@override_settings(SECURE_PROXY_SSL_HEADER=("HTTP_X_FORWARDED_PROTO", "https"))
+ def test_set_with_xheader_leftmost_right(self):
+ req = HttpRequest()
+ req.META["HTTP_X_FORWARDED_PROTO"] = "https, http"
+ self.assertIs(req.is_secure(), True)
+ req.META["HTTP_X_FORWARDED_PROTO"] = "https , http"
+ self.assertIs(req.is_secure(), True)
+
+ @override_settings(SECURE_PROXY_SSL_HEADER=("HTTP_X_FORWARDED_PROTO", "https"))
+ def test_set_with_xheader_leftmost_not_secure(self):
+ req = HttpRequest()
+ req.META["HTTP_X_FORWARDED_PROTO"] = "http, https"
+ self.assertIs(req.is_secure(), False)
+
+ @override_settings(SECURE_PROXY_SSL_HEADER=("HTTP_X_FORWARDED_PROTO", "https"))
+ def test_set_with_xheader_multiple_not_secure(self):
+ req = HttpRequest()
+ req.META["HTTP_X_FORWARDED_PROTO"] = "http ,wrongvalue,http,http"
+ self.assertIs(req.is_secure(), False)
+
+ @override_settings(SECURE_PROXY_SSL_HEADER=("HTTP_X_FORWARDED_PROTO", "https"))
def test_xheader_preferred_to_underlying_request(self):
class ProxyRequest(HttpRequest):
def _get_scheme(self):