Hi folks - a question please on writing provider t...
# pact-js
s
Hi folks - a question please on writing provider tests when the Content-Type is
application/x-www-form-urlencoded
The incoming body has been transformed into a format that isn't x-www-form-urlencoded. Is there anything obvious that I've done? I can't find many examples of this Content-Type. Request body in pact file:
"grant_type=client_credentials"
See the incoming request going to our mock server:
Copy code
[19:26:50.985] DEBUG (89255): pact@13.1.1: incoming request: {"body":{"grant_type=client_credentials":""},"headers":{"content-type":"application/x-www-form-urlencoded","authorization":"Basic badDummySecret","accept":"*/*","accept-encoding":"gzip, deflate","host":"127.0.0.1:53453","content-length":"31"},"method":"POST","path":"/token"}
Minimal pact file in comments. Thanks!
Minimal pact file:
Copy code
{
  "consumer": {
    "name": "Consumer"
  },
  "interactions": [
    {
      "_id": "52ca544e-b410-490d-8643-df13b8ca4648",
      "description": "Invalid basic auth credentials",
      "providerStates": [
        {
          "name": "badDummySecret is not a valid basic auth secret"
        },
        {
          "name": "mockComponentId is the component ID"
        }
      ],
      "request": {
        "body": "grant_type=client_credentials",
        "headers": {
          "Authorization": "Basic badDummySecret",
          "Content-Type": "application/x-www-form-urlencoded"
        },
        "method": "POST",
        "path": "/token"
      },
      "response": {
        "status": 400
      }
    }
  ],
  "metadata": {
    "pact-jvm": {
      "version": "4.6.5"
    },
    "pactSpecification": {
      "version": "3.0.0"
    }
  },
  "provider": {
    "name": "Provider"
  },
  "createdAt": "2024-07-10T15:32:48+00:00"
}
m
I think it might be something to do with the proxy that runs in Pact JS. Could you please raise an issue with a repro on the pact js repo?
s
Thanks @Matt (pactflow.io / pact-js / pact-go) -> repro?
m
oh, sorry (howtorepro)
s
thanks very much - just seen the guidance on raising issues and it looks clear to me. Will do that soon!
thankyou 1