pact-foundation / pact-stub-server

Standalone pact stub server
MIT License
75 stars 19 forks source link

Why stub-server reply response to request that is not have exactly match headers value #38

Closed aicquewk closed 1 year ago

aicquewk commented 3 years ago

Hi Team,

I've try to do contract testing using Postman (to act as a consumer) to make a request to stub-server with the headers value that are not exactly matched with headers value in contract but the stub-server always reply with response in first interaction.

this is my headers in contract (without matching rules) "headers": { "resourceOwnerID": "LOS" }

and this is what I sent request to stub-server "headers": { "resourceOwnerID": "LOS-1234" }

Another thing is about request body, when I send just empty parenthesis { } or send with some missing fields, stub-server will reply status 404, this is make senses. But If I not provide anything in request body, stub-server still reply me with response that matched with API path, this is not make any senses.

Is this a bug or limitation or something else?

Thanks for your help :)

uglyog commented 3 years ago

The stub server will try to find the closest matching request and respond with that. It has been written to support application prototyping so always tries to return a response.

aicquewk commented 3 years ago

Is it better if it respond status 404 instead of the closest response(false positive)? Because it shouldn't matched any request unless we write matching rules to handle not (exactly)matched request.

uglyog commented 3 years ago

You're probably looking for a regular mock server. You can use either https://github.com/pact-foundation/pact-ruby-standalone/releases or https://docs.pact.io/implementation_guides/rust/pact_mock_server_cli