def test_https(self):
# If the request is for HTTPS and the next url is HTTPS, then that
# works with all Djangos.
req = self.factory.get(
'/',
data={'next': 'https://testserver/foo'},
secure=True,
)
self.assertEquals(req.is_secure(), True)
next_url = views.get_next_url(req, 'next')
self.assertEqual(next_url, 'https://testserver/foo')
# For Django 1.11+, if the request is for HTTPS and the next url is
# HTTP, then that fails.
if django.VERSION >= (1, 11):
req = self.factory.get(
'/',
data={'next': 'http://testserver/foo'},
secure=True,
)
self.assertEquals(req.is_secure(), True)
next_url = views.get_next_url(req, 'next')
self.assertEqual(next_url, None)
评论列表
文章目录