Loading tests/csrf_tests/tests.py +13 −15 Original line number Diff line number Diff line Loading @@ -90,8 +90,8 @@ class CsrfViewMiddlewareTest(SimpleTestCase): def test_process_view_token_too_long(self): """ Check that if the token is longer than expected, it is ignored and a new token is created. If the token is longer than expected, it is ignored and a new token is created. """ req = self._get_GET_no_csrf_cookie_request() req.COOKIES[settings.CSRF_COOKIE_NAME] = 'x' * 10000000 Loading Loading @@ -311,7 +311,7 @@ class CsrfViewMiddlewareTest(SimpleTestCase): @override_settings(ALLOWED_HOSTS=['www.example.com']) def test_https_malformed_referer(self): """ Test that a POST HTTPS request with a bad referer is rejected A POST HTTPS request with a bad referer is rejected. """ req = self._get_POST_request_with_token() req._is_secure_override = True Loading @@ -329,7 +329,7 @@ class CsrfViewMiddlewareTest(SimpleTestCase): @override_settings(ALLOWED_HOSTS=['www.example.com']) def test_https_good_referer(self): """ Test that a POST HTTPS request with a good referer is accepted A POST HTTPS request with a good referer is accepted. """ req = self._get_POST_request_with_token() req._is_secure_override = True Loading @@ -341,8 +341,8 @@ class CsrfViewMiddlewareTest(SimpleTestCase): @override_settings(ALLOWED_HOSTS=['www.example.com']) def test_https_good_referer_2(self): """ Test that a POST HTTPS request with a good referer is accepted where the referer contains no trailing slash A POST HTTPS request with a good referer is accepted where the referer contains no trailing slash. """ # See ticket #15617 req = self._get_POST_request_with_token() Loading @@ -367,8 +367,7 @@ class CsrfViewMiddlewareTest(SimpleTestCase): def test_ensures_csrf_cookie_no_middleware(self): """ Tests that ensures_csrf_cookie decorator fulfils its promise with no middleware The ensure_csrf_cookie() decorator works without middleware. """ @ensure_csrf_cookie def view(request): Loading @@ -382,8 +381,8 @@ class CsrfViewMiddlewareTest(SimpleTestCase): def test_ensures_csrf_cookie_with_middleware(self): """ Tests that ensures_csrf_cookie decorator fulfils its promise with the middleware enabled. The ensure_csrf_cookie() decorator works with the CsrfViewMiddleware enabled. """ @ensure_csrf_cookie def view(request): Loading @@ -399,7 +398,7 @@ class CsrfViewMiddlewareTest(SimpleTestCase): def test_ensures_csrf_cookie_no_logging(self): """ Tests that ensure_csrf_cookie doesn't log warnings. See #19436. ensure_csrf_cookie() doesn't log warnings (#19436). """ @ensure_csrf_cookie def view(request): Loading @@ -425,8 +424,7 @@ class CsrfViewMiddlewareTest(SimpleTestCase): def test_csrf_cookie_age(self): """ Test to verify CSRF cookie age can be set using settings.CSRF_COOKIE_AGE. CSRF cookie age can be set using settings.CSRF_COOKIE_AGE. """ req = self._get_GET_no_csrf_cookie_request() Loading @@ -447,8 +445,8 @@ class CsrfViewMiddlewareTest(SimpleTestCase): def test_csrf_cookie_age_none(self): """ Test to verify CSRF cookie age does not have max age set and therefore uses session-based cookies. CSRF cookie age does not have max age set and therefore uses session-based cookies. """ req = self._get_GET_no_csrf_cookie_request() Loading Loading
tests/csrf_tests/tests.py +13 −15 Original line number Diff line number Diff line Loading @@ -90,8 +90,8 @@ class CsrfViewMiddlewareTest(SimpleTestCase): def test_process_view_token_too_long(self): """ Check that if the token is longer than expected, it is ignored and a new token is created. If the token is longer than expected, it is ignored and a new token is created. """ req = self._get_GET_no_csrf_cookie_request() req.COOKIES[settings.CSRF_COOKIE_NAME] = 'x' * 10000000 Loading Loading @@ -311,7 +311,7 @@ class CsrfViewMiddlewareTest(SimpleTestCase): @override_settings(ALLOWED_HOSTS=['www.example.com']) def test_https_malformed_referer(self): """ Test that a POST HTTPS request with a bad referer is rejected A POST HTTPS request with a bad referer is rejected. """ req = self._get_POST_request_with_token() req._is_secure_override = True Loading @@ -329,7 +329,7 @@ class CsrfViewMiddlewareTest(SimpleTestCase): @override_settings(ALLOWED_HOSTS=['www.example.com']) def test_https_good_referer(self): """ Test that a POST HTTPS request with a good referer is accepted A POST HTTPS request with a good referer is accepted. """ req = self._get_POST_request_with_token() req._is_secure_override = True Loading @@ -341,8 +341,8 @@ class CsrfViewMiddlewareTest(SimpleTestCase): @override_settings(ALLOWED_HOSTS=['www.example.com']) def test_https_good_referer_2(self): """ Test that a POST HTTPS request with a good referer is accepted where the referer contains no trailing slash A POST HTTPS request with a good referer is accepted where the referer contains no trailing slash. """ # See ticket #15617 req = self._get_POST_request_with_token() Loading @@ -367,8 +367,7 @@ class CsrfViewMiddlewareTest(SimpleTestCase): def test_ensures_csrf_cookie_no_middleware(self): """ Tests that ensures_csrf_cookie decorator fulfils its promise with no middleware The ensure_csrf_cookie() decorator works without middleware. """ @ensure_csrf_cookie def view(request): Loading @@ -382,8 +381,8 @@ class CsrfViewMiddlewareTest(SimpleTestCase): def test_ensures_csrf_cookie_with_middleware(self): """ Tests that ensures_csrf_cookie decorator fulfils its promise with the middleware enabled. The ensure_csrf_cookie() decorator works with the CsrfViewMiddleware enabled. """ @ensure_csrf_cookie def view(request): Loading @@ -399,7 +398,7 @@ class CsrfViewMiddlewareTest(SimpleTestCase): def test_ensures_csrf_cookie_no_logging(self): """ Tests that ensure_csrf_cookie doesn't log warnings. See #19436. ensure_csrf_cookie() doesn't log warnings (#19436). """ @ensure_csrf_cookie def view(request): Loading @@ -425,8 +424,7 @@ class CsrfViewMiddlewareTest(SimpleTestCase): def test_csrf_cookie_age(self): """ Test to verify CSRF cookie age can be set using settings.CSRF_COOKIE_AGE. CSRF cookie age can be set using settings.CSRF_COOKIE_AGE. """ req = self._get_GET_no_csrf_cookie_request() Loading @@ -447,8 +445,8 @@ class CsrfViewMiddlewareTest(SimpleTestCase): def test_csrf_cookie_age_none(self): """ Test to verify CSRF cookie age does not have max age set and therefore uses session-based cookies. CSRF cookie age does not have max age set and therefore uses session-based cookies. """ req = self._get_GET_no_csrf_cookie_request() Loading