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
added request headers matching #89
Conversation
I also would like this feature implemented. |
+1 |
Hello! Our apologies for the very delayed response, we're just starting to ramp this project back into active development. I like this update and we'd like to get it in, but there are some things to address. Check the line notes in the commit for some of those comments, but first of all there is a merge conflict (the current repo is 2 patch versions ahead of your file). Also, we're using tab indentation, can you update that please? Thank you for adding tests!! Many people forget about that. Can you add 1 more test? We need to see that the response is correct when there are multiple headers expected and the correct multiple headers are provided. Last thing: can we enhance the header matching to be either exact string or regex? If you need help with that let us know! |
// Inspect the request headers submitted | ||
if ( handler.requestHeaders ) | ||
{ | ||
console.log("checking headers"); |
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.
We need to use $.mockjaxSettings.log(...)
for these log calls to support older browsers.
@vizio360 I haven't heard back from you on this PR. If you aren't interested in continuing the work I'd be happy to help out. Please let us know if that's the case and I'll switch this PR to a new branch and start the modifications. Thanks! |
@jakerella just finished updating the code. Gonna put it up soon. |
@jakerella I've created a new pull request (#193) as I do not have access to the previous fork. |
Added the ability to match request headers.
I'm in the middle of testing some oauth2 services and I needed an easy way to create mocks which would be valid only if an
Authorization
header was sent in the request.This pull requests adds a new property you can define in the mockjax options object called
requestHeaders
.requestHeaders
is just an object with key, value pairs defining which headers are needed by the request to be validated.here is an example which will match all the requests to /me only if the request includes an header called
Authorization
with value"Bearer vsdfjsdf+adfvadfv="