test_views.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:mozilla-django-oidc 作者: mozilla 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号