Postman mock servers force require Authorization header

I’ve tried searching existing topics and the closest I found was: Basic Auth Example Using Mock Server which had no answers.

I’m trying to simulate the authentication on my postman mock servers by making the mock responses return 200 only when both x-api-key and Authorization headers are passed.
I’ve enforced the x-api-key header requirement simply by making the mock server private.
How would I configure my mock server to return a 401 example response if the Authorization header is empty?

I have tried creating 2 example responses:

  • Return status code 200 where I set Authorization header as random values
  • Return status code 401 where I hide Authorization

Unfortunately, creating the above two example requests did not satisfy that I am trying to achieve.

As far as I know, there are no matching rules for headers. So your scenario is not possible using the Postman mock server.

You have two options:

  • you give up on the case with testing for the failure (401)
  • you search another mocking tool (I had a good experience with WireMock, but that is a proper mock server that needs configuring, …)