Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pact parser is removing quoting on Content-Type params #1538

Open
fragonib opened this issue Apr 27, 2022 · 3 comments
Open

Pact parser is removing quoting on Content-Type params #1538

fragonib opened this issue Apr 27, 2022 · 3 comments
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@fragonib
Copy link

fragonib commented Apr 27, 2022

Hi 👋 ,

Is this by design or a BUG?

  1. You are running a PROVIDER Contract Test that fetches contracts to validate from PactBroker
  2. The PACT framework parses contract coming from defined PactBroker
  3. This particular contract has this header
    Content-Type: multipart/related; type="application/json"; boundary=myBoundary
  4. When parsing this contract quotes disappear on PACT Request Model (that can be ok)
  5. But when PACT serializes the Request Model the generated header miss quotes so is outside standard when param values has special symbols like / as in type in this particular case:
    Content-Type: multipart/related; type=application/json; boundary=myBoundary

I'm having issues during provider verification because generated request doesn't contain quotes and provider requires them to dispatch it

@fragonib
Copy link
Author

I guess this can be useful: https://www.w3.org/Protocols/rfc1341/4_Content-Type.html

@fragonib
Copy link
Author

The involved code is in class au.com.dius.pact.core.model.HeaderParser. This serialization code isn´t dealing with quotes

private fun hvToString(headerValue: HeaderValue): String {
  return if (headerValue.params.isEmpty()) {
    headerValue.value.trim()
  } else {
    headerValue.value.trim() + ";" + headerValue.params.joinToString(";") { it.name + "=" + it.value }
  }
}

@timoschroeder1213
Copy link

Hi there,
we're also having a problem with this. We should send an Accept Header with Accept: application/hal+json;profile="https://api.example.de/examples+v1" and receive the same value in the Content-Type Header. When using a pact file for the test and sending a query the quoting is removed and the test fails.

@rholshausen rholshausen added the bug Indicates an unexpected problem or unintended behavior label Jul 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

3 participants