pact-foundation/pact-provider-verifier

pact-provider-verifier copies entity-body of DELETE requests into query string

ewortzman opened this issue · 1 comments

To replicate:

  1. clone this repo
  2. in the root, execute python reflect.py. This starts a simple server that accepts requests, prints the request received, and responds with a 200
  3. run pact-provider-verifier ./pacts/myconsumer-myprovider.json -h http://localhost:8081

In the reflect server, you should see:

----- Request Start -----
/api/cool/stuff
Host: localhost:8081
Cookie:
X-Forwarded-For: 127.0.0.1
Content-Length: 13
Content-Type: application/x-www-form-urlencoded

{'foo': 'bar'}
-------------------------
127.0.0.1 - - [12/Dec/2017 21:08:27] "DELETE /api/cool/stuff HTTP/1.1" 200 -
------ Request End ------

You will see:

----- Request Start -----
/api/cool/stuff?%7B%22foo%22%3A%22bar%22%7D
Host: localhost:8081
Cookie:
X-Forwarded-For: 127.0.0.1
Content-Length: 0

-------------------------
127.0.0.1 - - [12/Dec/2017 21:09:09] "DELETE /api/cool/stuff?%7B%22foo%22%3A%22bar%22%7D HTTP/1.1" 200 -
------ Request End ------

You can see that the body of the request has been copied into the query string.

See this stack overflow discussion

While the spec does state that an entity-body in a DELETE request should be ignored by the server, the request itself is not forbidden from containing one. As such, pact should be capable of sending a DELETE request that contains a body, in order to test that the provider properly handles such a request. Especially since the ability to create a query string already exists by using a query field.

This is the behaviour of the underlying Ruby Rack Test framework, and is unfortunately code that I do not control. I would suggest that the feedback that the tools are giving you is that you're doing something very unconventional, and should consider achieving your goal another way. Can you explain what your objective is? Someone may have an idea of how to achieve it in a conventional way.