Skip to content

Commit

Permalink
Merge pull request #278 from mozilla-services/fix_cors_expose_headers
Browse files Browse the repository at this point in the history
Wrong if clause that passed even if wrong on Python 2.*
  • Loading branch information
almet committed Feb 26, 2015
2 parents ef50391 + 2c9f0ca commit df5b558
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cornice/cors.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def apply_cors_post_request(service, request, response):
'Access-Control-Allow-Credentials' not in response.headers):
response.headers['Access-Control-Allow-Credentials'] = 'true'

if request.method is not 'OPTIONS':
if request.method != 'OPTIONS':
# Which headers are exposed?
supported_headers = service.cors_supported_headers
if supported_headers:
Expand Down
8 changes: 8 additions & 0 deletions cornice/tests/test_cors.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ def test_preflight_missing_origin(self):
status=400)
self.assertEqual(len(resp.json['errors']), 1)

def test_preflight_does_not_expose_headers(self):
resp = self.app.options(
'/squirel',
headers={'Access-Control-Request-Method': 'GET',
'Origin': 'notmyidea.org'},
status=200)
self.assertNotIn('Access-Control-Expose-Headers', resp.headers)

def test_preflight_missing_request_method(self):

resp = self.app.options(
Expand Down

0 comments on commit df5b558

Please sign in to comment.