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 '.*'")
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 '.*'")
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")
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")
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))
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))
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))