Пример #1
0
    def test_logs_rejection(self):
        self.create_mock('beachfront.middleware.ENFORCE_HTTPS', new=True)
        self.request.is_secure = False

        middleware.https_filter()

        self.assertEqual([
            'WARNING - Rejecting non-HTTPS request: endpoint=`/test-path` referrer=`http://test-referrer`',
        ], self.logger.lines)
Пример #2
0
    def test_when_enabled_allows_https_requests(self):
        self.create_mock('beachfront.middleware.ENFORCE_HTTPS', new=True)
        self.request.is_secure = True

        response = middleware.https_filter()

        self.assertIsNone(response)
Пример #3
0
    def test_when_enabled_rejects_non_https_requests(self):
        self.create_mock('beachfront.middleware.ENFORCE_HTTPS', new=True)
        self.request.is_secure = False

        response = middleware.https_filter()

        self.assertEqual(('Access Denied: Please retry with HTTPS', 403),
                         response)