コード例 #1
0
ファイル: tests.py プロジェクト: pombredanne/django-sslify
    def test_custom_ssl_port(self):
        custom_port = 8443
        with self.settings(SSLIFY_PORT=custom_port):
            request = self.factory.get('/woot/')
            middleware = SSLifyMiddleware()
            request = middleware.process_request(request)

            self.assertEqual(custom_port, urlsplit(request['Location']).port)
コード例 #2
0
    def test_custom_ssl_port(self):
        custom_port = 8443
        with self.settings(SSLIFY_PORT=custom_port):
            request = self.factory.get('/woot/')
            middleware = SSLifyMiddleware()
            request = middleware.process_request(request)

            self.assertEqual(custom_port, urlsplit(request['Location']).port)
コード例 #3
0
    def test_perma_redirects_http_to_https(self):
        request = self.factory.get('/woot/')
        self.assertTrue(request.build_absolute_uri().startswith('http://'))

        middleware = SSLifyMiddleware()
        result = middleware.process_request(request)

        self.assert_https_redirect(result)
        self.assertEqual(443, urlsplit(result['Location']).port)
コード例 #4
0
ファイル: tests.py プロジェクト: MikeHibbert/django-sslify
    def test_perma_redirects_http_to_https(self):
        request = self.factory.get('/woot/')
        self.assertTrue(request.build_absolute_uri().startswith('http://'))

        middleware = SSLifyMiddleware()
        result = middleware.process_request(request)

        self.assert_https_redirect(result)
        self.assertEqual(443, urlsplit(result['Location']).port)
コード例 #5
0
    def test_disable_for_url(self):
        def sslify_disable(request):
            return request.get_full_path().startswith('/disabled')

        with self.settings(SSLIFY_DISABLE_FOR_REQUEST=[sslify_disable]):
            middleware = SSLifyMiddleware()
            request = self.factory.get('/disabled/')
            request = middleware.process_request(request)
            self.assertIsNone(request)

            request = self.factory.get('/enabled/')
            result = middleware.process_request(request)
            self.assert_https_redirect(result)
コード例 #6
0
ファイル: tests.py プロジェクト: MikeHibbert/django-sslify
    def test_disable_for_url(self):
        def sslify_disable(request):
            return request.get_full_path().startswith('/disabled')

        with self.settings(SSLIFY_DISABLE_FOR_REQUEST=[sslify_disable]):
            middleware = SSLifyMiddleware()
            request = self.factory.get('/disabled/')
            request = middleware.process_request(request)
            self.assertIsNone(request)

            request = self.factory.get('/enabled/')
            result = middleware.process_request(request)
            self.assert_https_redirect(result)