diff options
| author | Przemysław Suliga <mail@suligap.net> | 2016-08-19 14:32:21 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-08-19 19:16:00 -0400 |
| commit | 1f68bb5683608ebe1ce47f0c9d37dad9482d1df9 (patch) | |
| tree | 7882a425ade1cb5cc852d7c890f4409f67629bd9 /tests | |
| parent | 549b90fab33c80d1ba6575d4837ea52d79f70fb1 (diff) | |
Refs #26902 -- Protected against insecure redirects in set_language().
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/view_tests/tests/test_i18n.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/view_tests/tests/test_i18n.py b/tests/view_tests/tests/test_i18n.py index e1cf44782d..ae56990fe6 100644 --- a/tests/view_tests/tests/test_i18n.py +++ b/tests/view_tests/tests/test_i18n.py @@ -54,6 +54,23 @@ class I18NTests(TestCase): self.assertEqual(response.url, '/') self.assertEqual(self.client.session[LANGUAGE_SESSION_KEY], lang_code) + def test_setlang_http_next(self): + """ + The set_language view only redirects to the 'next' argument if it is + "safe" and its scheme is https if the request was sent over https. + """ + lang_code = self._get_inactive_language_code() + non_https_next_url = 'http://testserver/redirection/' + post_data = dict(language=lang_code, next=non_https_next_url) + # Insecure URL in POST data. + response = self.client.post('/i18n/setlang/', data=post_data, secure=True) + self.assertEqual(response.url, '/') + self.assertEqual(self.client.session[LANGUAGE_SESSION_KEY], lang_code) + # Insecure URL in HTTP referer. + response = self.client.post('/i18n/setlang/', secure=True, HTTP_REFERER=non_https_next_url) + self.assertEqual(response.url, '/') + self.assertEqual(self.client.session[LANGUAGE_SESSION_KEY], lang_code) + def test_setlang_redirect_to_referer(self): """ The set_language view redirects to the URL in the referer header when |
