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

Using the x-mock-match-request-headers will not return default response when header is not passed #8065

Closed
jwbanning opened this issue Feb 14, 2020 · 3 comments
Assignees

Comments

@jwbanning
Copy link

jwbanning commented Feb 14, 2020

Describe the bug
While using a the x-mock-match-request-headers against my mock server, the default response is not returned when nothing is passed in the header.

To Reproduce
Steps to reproduce the behavior:

  1. Set up a mock server with 3 examples.
    a. Default example. Response should be
{
	number:default
}

default

b. Example ONE.  key: values of number:one is set for the header. Response should be 
{
	number:one
}

one

c. example named TWO when a key: values of number:two is set for the header. Response should be

{
	number:two
}

two

  1. Send the request with the different header parameters:
    number: one | two
    x-mock-match-request-headers: number

Screen Shot 2020-02-14 at 11 29 29 AM

This works correctly.
  1. Send the request without any header parameters

Screen Shot 2020-02-14 at 11 29 29 AM

and the response is the example when the header value is one:

{
	number:one
}

Expected behavior
When nothing is passed in the header, the default response would return.

I have made a couple videos that I can share to illustrate the issue.

@pranayat
Copy link

pranayat commented Feb 18, 2020

Hi,
When nothing is passed in the header then all 3 examples become equal candidates for a response and one of them is chosen.
This happens because when the x-mock-match-request-headers header is not sent (or no value is set therein), the headers set in the example requests are ignored.
Hence, the examples 'default', 'ONE' and 'TWO' are all treated equally (I'm assuming they all have the same path). In your case, example 'ONE' was chosen.
Do let me know if this cleared things up. If not, do share the videos you made.

@jwbanning
Copy link
Author

jwbanning commented Feb 18, 2020 via email

@pranayat
Copy link

pranayat commented Feb 19, 2020

All 3 examples are identical if their headers are ignored. The headers are ignored if the x-mock-match-request-headers header is not sent (or is empty). Hence any one of the 3 may be chosen (though the same one will be chosen every time). There is no construct of 'priority' or 'ordering' or 'default' among identical examples in Postman currently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants