-
Notifications
You must be signed in to change notification settings - Fork 70
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
Making CORS work #2
Conversation
( (headers_from(env)["Access-Control-Request-Headers"].nil? ? false | ||
: headers_from(env)["Access-Control-Request-Headers"].match(/x-pact-mock-service/) | ||
) || headers_from(env)['X-Pact-Mock-Service'] ) && | ||
env['PATH_INFO'] == request_path && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find these lines a bit hard to reason about. Could we pull the two scenarios out into a separate methods with meaningful names?
A test can be written in this way: https://github.com/bethesque/pact-mock_service/blob/master/spec/features/mock_one_response_spec.rb To make it configurable how about:
|
Leave it with me, I see an easy way to get it all to work. André Allavena, PhD Suite 22, 20 Park Rd |
…headers to be added to mocked answers
I've updated my code and the PR. Functionality is now
Testing needs to happen via browsers and different setup, to make sure I Assuming this works and pending code review, there is now no need to Thanks André Allavena, PhD Suite 22, 20 Park Rd |
I'm trying to get my head around this scenario. When the real life code has needed CORS in the past, we have just set up a CORS interaction in the same way that we set up any other interaction. The CORS headers are then written to the pact, and are verified against the provider. The code you have written is to support the use case where the real life code does not need CORS, but tests need CORS because the testing framework considers the mock service to be on a different "domain", so the tests automatically perform the extra OPTIONS/CORS requests. The CORS headers are NOT written to the pact because there were no expectations set up for them, and are therefore not verified against the provider. Is this correct? |
rescue StandardError => e | ||
@logger.error 'Error ocurred in mock service:' | ||
@logger.ap e, :error | ||
puts e.inspect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed?
Yes, you are absolutely correct. Beth wrote on 02/01/15 12:59:
André Allavena, PhD Suite 22, 20 Park Rd |
Have merged and released v0.2.3.pre.rc2. Will be changing the CLI --cors-enabled to something else, so not doing a proper release yet. |
Adding handling of browser "OPTIONS" web call (which is a call made by browsers prior to issuing a POST or DELETE in CORS cases)