def testValidCORSRequest(self):
"""
Sanity check to make sure we get the valid headers back for a CORS
based request.
"""
agent = Agent(reactor)
headers = Headers()
# The origin to use in the tests
dummy_origin = 'http://foo.com'
headers.addRawHeader('Origin', dummy_origin)
response = yield agent.request('GET', self.uri, headers)
# Check we get the correct status.
self.assertEqual(http.OK, response.code)
# Check we get the right headers back
self.assertTrue(
response.headers.hasHeader('Access-Control-Allow-Origin'))
self.assertTrue(
response.headers.hasHeader('Access-Control-Allow-Credentials'))
self.assertTrue(
dummy_origin in
response.headers.getRawHeaders('Access-Control-Allow-Origin'))
评论列表
文章目录