Skip to content

Commit

Permalink
Add unit test for CherryPy CORS tool
Browse files Browse the repository at this point in the history
  • Loading branch information
niflostancu committed Dec 6, 2019
1 parent cbc20c2 commit ea2feb5
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/unit/netapi/test_rest_cherrypy.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,19 @@ def test_yaml_ctype(self):
))
self.assertEqual(response.status, '200 OK')
self.assertDictEqual(request.unserialized_data, data)


class TestCors(BaseToolsTest):
def __get_cp_config__(self):
return {
'tools.cors_tool.on': True,
}

def test_option_request(self):
request, response = self.request(
'/', method='OPTIONS', headers=(
('Origin', 'https://domain.com'),
))
self.assertEqual(response.status, '200 OK')
self.assertEqual(response.headers.get(
'Access-Control-Allow-Origin'), 'https://domain.com')

0 comments on commit ea2feb5

Please sign in to comment.