示例#1
0
    def test_normal_request(self):
        request = self.factory.get('/foo/')
        self.assertTrue(request.build_absolute_uri().startswith('http://'))

        middleware = SSLifyAdminMiddleware()
        request = middleware.process_request(request)

        self.assertIsNone(request)
示例#2
0
    def test_normal_request(self):
        request = self.factory.get('/foo/')
        self.assertTrue(request.build_absolute_uri().startswith('http://'))

        middleware = SSLifyAdminMiddleware()
        request = middleware.process_request(request)

        self.assertIsNone(request)
示例#3
0
    def test_admin_redirects_http_to_https(self):
        request = self.factory.get('/admin_custom_namespace/')
        self.assertTrue(request.build_absolute_uri().startswith('http://'))

        middleware = SSLifyAdminMiddleware()
        request = middleware.process_request(request)

        self.assertIsInstance(request, HttpResponsePermanentRedirect)
        self.assertTrue(request['Location'].startswith('https://'))
示例#4
0
    def test_admin_redirects_http_to_https(self):
        request = self.factory.get('/admin_custom_namespace/')
        self.assertTrue(request.build_absolute_uri().startswith('http://'))

        middleware = SSLifyAdminMiddleware()
        request = middleware.process_request(request)

        self.assertIsInstance(request, HttpResponsePermanentRedirect)
        self.assertTrue(request['Location'].startswith('https://'))
示例#5
0
    def test_admin_redirects_http_to_https(self):
        sslify_admin_url = getattr(settings, 'SSLIFY_ADMIN_URL', 'admin/')
        request = self.factory.get('/' + sslify_admin_url)
        self.assertTrue(request.build_absolute_uri().startswith('http://'))

        middleware = SSLifyAdminMiddleware()
        request = middleware.process_request(request)

        self.assertIsInstance(request, HttpResponsePermanentRedirect)
        self.assertTrue(request['Location'].startswith('https://'))