summaryrefslogtreecommitdiff
path: root/tests/settings_tests
diff options
context:
space:
mode:
authorAdam Chainz <me@adamj.eu>2016-12-22 23:52:50 +0000
committerTim Graham <timograham@gmail.com>2016-12-22 18:52:50 -0500
commit8fb82a315a2a2827c5b91ce1190f2d6f0c8d977b (patch)
treebb9ca949b94d9ba69e8d8bfe281e778010f34f14 /tests/settings_tests
parentda792400503265a80e5307f17e59b65ec88694aa (diff)
Used @override_settings for SECURE_PROXY_SSL_HEADER tests.
Diffstat (limited to 'tests/settings_tests')
-rw-r--r--tests/settings_tests/tests.py15
1 files changed, 4 insertions, 11 deletions
diff --git a/tests/settings_tests/tests.py b/tests/settings_tests/tests.py
index 14a3b793ca..8f50a854e4 100644
--- a/tests/settings_tests/tests.py
+++ b/tests/settings_tests/tests.py
@@ -389,32 +389,25 @@ class TrailingSlashURLTests(SimpleTestCase):
class SecureProxySslHeaderTest(SimpleTestCase):
- settings_module = settings
-
- def setUp(self):
- self._original_setting = self.settings_module.SECURE_PROXY_SSL_HEADER
-
- def tearDown(self):
- self.settings_module.SECURE_PROXY_SSL_HEADER = self._original_setting
+ @override_settings(SECURE_PROXY_SSL_HEADER=None)
def test_none(self):
- self.settings_module.SECURE_PROXY_SSL_HEADER = None
req = HttpRequest()
self.assertIs(req.is_secure(), False)
+ @override_settings(SECURE_PROXY_SSL_HEADER=('HTTP_X_FORWARDED_PROTOCOL', 'https'))
def test_set_without_xheader(self):
- self.settings_module.SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTOCOL', 'https')
req = HttpRequest()
self.assertIs(req.is_secure(), False)
+ @override_settings(SECURE_PROXY_SSL_HEADER=('HTTP_X_FORWARDED_PROTOCOL', 'https'))
def test_set_with_xheader_wrong(self):
- self.settings_module.SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTOCOL', 'https')
req = HttpRequest()
req.META['HTTP_X_FORWARDED_PROTOCOL'] = 'wrongvalue'
self.assertIs(req.is_secure(), False)
+ @override_settings(SECURE_PROXY_SSL_HEADER=('HTTP_X_FORWARDED_PROTOCOL', 'https'))
def test_set_with_xheader_right(self):
- self.settings_module.SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTOCOL', 'https')
req = HttpRequest()
req.META['HTTP_X_FORWARDED_PROTOCOL'] = 'https'
self.assertIs(req.is_secure(), True)