postmanlabs / postman-app-support

Postman is an API platform for building and using APIs. Postman simplifies each step of the API lifecycle and streamlines collaboration so you can create better APIs—faster.
https://www.postman.com
5.86k stars 841 forks source link

Mock Servers: Adding headers to the client request anti-pattern #8534

Open vdespa opened 4 years ago

vdespa commented 4 years ago

Describe the bug While I am very happy that the Postman Mock functionality has been improved, I would still like to raise awareness about something I consider to be an anti-pattern.

To Reproduce Currently, to get a specific behavior, you are forced to add some headers, like "x-mock-match-request-body" to match the body.

Other examples:

Any configurations you be stored within the mock server and configured from the UI, not from headers.

I don't think it is a good idea to modify the requests that the client sends (even if it is just a header). Ideally, I should be able to switch the server with a mock server and not change the request at all.

Expected behavior No mock headers should be required and the matching algorithm should try to find the closest match.

The request should remain the same.

mnuzzo-datto commented 3 years ago

I agree - requiring that users modify the system under test to send these headers is sub-optimal and risks introducing further bugs.

jjduarte commented 2 years ago

I agree. I'd say that this should be either handled by the matching algorithm or configurable in the Mock Server creation setup. E.g.: When create a Mock Server flagged to match body request by default and no need to send the x-mock-match-request-body in the request. Same for headers...etc.

hungdao-testing commented 2 years ago

+1, should not change the request header. The reason is as my last comment on #10970