コード例 #1
0
ファイル: preflight_tests.py プロジェクト: masuka/python-cors
    def test_post_content_types(self):
        response = _response()
        request = _request(method="POST", headers={"Content-Type": "application/json"})

        with self.assertRaises(preflight.AccessControlError) as context:
            preflight.check_headers(response, request)

        self.assertRegexpMatches(
            context.exception.message,
            "Headers .+ not allowed for resource '.*'")
コード例 #2
0
    def test_post_content_types(self):
        response = _response()
        request = _request(method="POST",
                           headers={"Content-Type": "application/json"})

        with self.assertRaises(preflight.AccessControlError) as context:
            preflight.check_headers(response, request)

        self.assertRegexpMatches(context.exception.message,
                                 "Headers .+ not allowed for resource '.*'")
コード例 #3
0
ファイル: preflight_tests.py プロジェクト: masuka/python-cors
    def test_simple_headers(self):
        preflight.check_method(_response(), _request(headers={"Accept": "foo"}))
        preflight.check_method(_response(), _request(headers={"Content-Type": "application/json"}))

        with self.assertRaises(preflight.AccessControlError) as context:
            preflight.check_headers(
                _response(),
                _request(headers={"X-Auth-Token": "foo"}))

        self.assertRegexpMatches(
            context.exception.message,
            "Headers .* not allowed")
コード例 #4
0
    def test_simple_headers(self):
        preflight.check_method(_response(),
                               _request(headers={"Accept": "foo"}))
        preflight.check_method(
            _response(),
            _request(headers={"Content-Type": "application/json"}))

        with self.assertRaises(preflight.AccessControlError) as context:
            preflight.check_headers(_response(),
                                    _request(headers={"X-Auth-Token": "foo"}))

        self.assertRegexpMatches(context.exception.message,
                                 "Headers .* not allowed")
コード例 #5
0
    def test_post_simple_content_type(self):
        response = _response()
        request = _request(method="POST",
                           headers={"Content-Type": "text/plain"})

        self.assertIsNone(preflight.check_headers(response, request))
コード例 #6
0
    def test_allowed_headers(self):
        response = _response(
            headers={"Access-Control-Allow-Headers": "X-Auth-Token"})
        request = _request(headers={"X-Auth-Token": "foo"})

        self.assertIsNone(preflight.check_headers(response, request))
コード例 #7
0
ファイル: preflight_tests.py プロジェクト: masuka/python-cors
    def test_allowed_headers(self):
        response = _response(headers={"Access-Control-Allow-Headers": "X-Auth-Token"})
        request = _request(headers={"X-Auth-Token": "foo"})

        self.assertIsNone(preflight.check_headers(response, request))
コード例 #8
0
ファイル: preflight_tests.py プロジェクト: masuka/python-cors
    def test_post_simple_content_type(self):
        response = _response()
        request = _request(method="POST", headers={"Content-Type": "text/plain"})

        self.assertIsNone(preflight.check_headers(response, request))