diff options
| author | Thomas Schmidt <thomas@useobject.com> | 2022-03-07 17:25:52 -0500 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-03-23 19:33:36 +0100 |
| commit | 1cf60ce6017d904024ee132f7edae0b4b821a954 (patch) | |
| tree | bb73a5fcca79e812f2c7182ddf68dadee7c49ea2 /tests/settings_tests/tests.py | |
| parent | d46e158ee21cb067a65d44699e6dce00b3dab8e3 (diff) | |
Fixed #33569 -- Added SECURE_PROXY_SSL_HEADER support for list of protocols in the header value.
Diffstat (limited to 'tests/settings_tests/tests.py')
| -rw-r--r-- | tests/settings_tests/tests.py | 20 |
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): |
