parroty / exvcr

HTTP request/response recording library for elixir, inspired by VCR.
MIT License
714 stars 133 forks source link

Normalizes request body and URL by parsing params to a list and sorting #211

Closed patrickberkeley closed 10 months ago

patrickberkeley commented 10 months ago

Before these changes, if the request body or URL contained a list of params that were in a different order than the params in the cassette, the request would fail to match the cassette.

As of OTP 26, map key order is not guaranteed, so request bodies and URL params that are created using maps can fail to match since the order of their keys is not idempotent.

These changes convert the request body and URL params to a sorted list before comparing it to the request body and URL in the cassette. This ensures cassettes will be matched as long as their request bodies and URL params contain the same set of key-value pairs as the incoming request.

coveralls commented 10 months ago

Coverage Status

coverage: 92.419% (+0.2%) from 92.248% when pulling a1d9dbc1d35f391fe1242cc6caf3d6a1cd3b407e on seated:pjb/normalize-response-body into 406af2df2842be49c30d4a9a3ce6620f9d4c2e17 on parroty:master.

coveralls commented 10 months ago

Coverage Status

coverage: 92.581% (+0.3%) from 92.248% when pulling a1d9dbc1d35f391fe1242cc6caf3d6a1cd3b407e on seated:pjb/normalize-response-body into 406af2df2842be49c30d4a9a3ce6620f9d4c2e17 on parroty:master.

parroty commented 10 months ago

Thank you!