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)
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://'))
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://'))