pact-foundation / pact-mock_service

Provides a mock service for use with Pact
https://pact.io
MIT License
72 stars 68 forks source link

Return more informative response codes #129

Open bethesque opened 3 years ago

bethesque commented 3 years ago

If no interaction with the path matches -> 404 If an interaction with the path matches but the headers/request is wrong -> 400/405 or 415

@uglyog if you can point to a test that shows how the rust one does it, it would be good to make them the same.

uglyog commented 3 years ago

The rust one is not correct either, because it returns a 500 on mismatch.

uglyog commented 3 years ago

The logic should be:

  1. Find all interactions the having a matching path
  2. If there are none:
    1. If it is an OPTIONS request, respond as per a CORS pre-flight request
    2. Otherwise, return a 404
  3. Match the request, and return the following:
    1. If there is a mismatch on the method: 405
    2. If a POST/PUT/PATCH and there is a mismatch on the content type: 415 (can skip this one)
    3. Else if a mismatch: 400 (reason for the 500 here is 400 responses may be present in the Pact file)
    4. Else return response from Pact file