Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for local OPTIONS CORS headers #444

Merged
merged 4 commits into from
Jul 31, 2017
Merged

Add support for local OPTIONS CORS headers #444

merged 4 commits into from
Jul 31, 2017

Conversation

stealthycoin
Copy link
Contributor

@stealthycoin stealthycoin commented Jul 29, 2017

Looks like I couldn't push directly to the #437 for some reason so I opened a separate PR.

closes #437
fixes #436

cc @kyleknap @jamesls

@codecov-io
Copy link

codecov-io commented Jul 29, 2017

Codecov Report

Merging #444 into master will increase coverage by 0.26%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #444      +/-   ##
==========================================
+ Coverage   93.61%   93.87%   +0.26%     
==========================================
  Files          18       18              
  Lines        2864     3153     +289     
  Branches      375      440      +65     
==========================================
+ Hits         2681     2960     +279     
- Misses        132      142      +10     
  Partials       51       51
Impacted Files Coverage Δ
chalice/local.py 96.95% <100%> (-0.55%) ⬇️
chalice/constants.py 100% <0%> (ø) ⬆️
chalice/analyzer.py 91.63% <0%> (+0.51%) ⬆️
chalice/deploy/deployer.py 95.02% <0%> (+1.29%) ⬆️
chalice/cli/__init__.py 83.69% <0%> (+1.82%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 42aae05...7060bb5. Read the comment docs.

@corespace
Copy link

Great commenting. I wasn't sure if you folks would like the change hence my quick-n-dirty fix. Thanks for reviewing!

chalice/local.py Outdated
cors_headers = cors_config.get_access_control_headers()

# The keys will be ordered in python 3 but in python 2 they will not
# be. To assert this header is sent correctly we need to introduce
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not necessarily true about the need to sort this for the assertion. You could always just split the header value by commas and assert that the sorted list is the same, but that is a bit more tedious. I only bring it up because it is a little weird to have this sorted in the core logic when it is only being sorted for the test. I'm about +0 in updating this especially since we do the same logic in the non chalice local tests (i.e. assert the header values in the a split list).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Talked offline about this. The reason it is being done is that there is not an easy way to parse the raw body and pull out the specific header/value without using something like the email library. Given that this is being ran in chalice local it is fine that it is getting sorted as chalice local is just a test mode. If this was being done in the actual lambda function, it would be something we would not want to do and should add the extra logic in the tests.

Copy link
Contributor

@kyleknap kyleknap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just had that one comment that I would like to be discussed, but otherwise it looks fine.

Copy link
Contributor

@kyleknap kyleknap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢

Added the Access-Control-Allow-Methods header to the local OPTIONS
response. Also updated the tests and added some comments to explain what
is going on in the _send_autogen_options_response method since it was a
little hard to follow.
@stealthycoin stealthycoin merged commit 778d082 into master Jul 31, 2017
@stealthycoin stealthycoin deleted the local-cors branch July 31, 2017 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

chalice local does not respect CORS config
5 participants