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

Vendor specific content types are not providing correct cross comparison #12

Closed
YOU54F opened this issue Sep 20, 2022 · 7 comments
Closed

Comments

@YOU54F
Copy link
Member

YOU54F commented Sep 20, 2022

Pre-condition

  • OAS response has vendor specific extension for Content-Type
  • Consumer may or may not add vendor specific extension for Content-Type into Pact
  • Consumer adds a field into the Pact, that provider doesn’t provide.

Vendor specific extension

headers: { “Content-Type”: “application/vnd.api+json” }

Repro https://github.com/pactflow/swagger-mock-validator/tree/vnd_issue/issues/vnd

  1. False Positive - If content-types are the same (other than application/json), detection is not taking place.
  • OAS has vendor specific extension = TRUE
  • Consumer has vendor specific extension = TRUE
npx @pactflow/swagger-mock-validator https://raw.githubusercontent.com/pactflow/swagger-mock-validator/vnd_issue/issues/vnd/repro/oas_vnd.yaml https://raw.githubusercontent.com/pactflow/swagger-mock-validator/vnd_issue/issues/vnd/pacts/pactflow-example-consumer-vnd-pactflow-example-provider.json
  1. Valid Failure ( Content Type & Extra Field )
  • OAS has vendor specific extension = FALSE
  • Consumer has vendor specific extension = TRUE
npx @pactflow/swagger-mock-validator https://raw.githubusercontent.com/pactflow/swagger-mock-validator/vnd_issue/issues/vnd/repro/oas.yaml https://raw.githubusercontent.com/pactflow/swagger-mock-validator/vnd_issue/issues/vnd/pacts/pactflow-example-consumer-vnd-pactflow-example-provider.json
  1. Valid Failure ( Extra Field )
  • OAS has vendor specific extension = FALSE
  • Consumer has vendor specific extension = FALSE
npx @pactflow/swagger-mock-validator https://raw.githubusercontent.com/pactflow/swagger-mock-validator/vnd_issue/issues/vnd/repro/oas.yaml https://raw.githubusercontent.com/pactflow/swagger-mock-validator/vnd_issue/issues/vnd/pacts/pactflow-example-consumer-pactflow-example-provider.json
  1. Valid Failure ( Content Type Mismatch )
  • OAS has vendor specific extension = TRUE
  • Consumer has vendor specific extension = FALSE
npx @pactflow/swagger-mock-validator https://raw.githubusercontent.com/pactflow/swagger-mock-validator/vnd_issue/issues/vnd/repro/oas_vnd.yaml https://raw.githubusercontent.com/pactflow/swagger-mock-validator/vnd_issue/issues/vnd/pacts/pactflow-example-consumer-pactflow-example-provider.json

Expected behaviour.

All above cases should fail validation.
If consumer and provider specify vendor specification application/json types (and other content-types), they should support the same validation as per regular mime times

@mefellows
Copy link
Contributor

Great work - thanks Yousaf! I'll add to our backlog for review and prioritisation.

@mefellows
Copy link
Contributor

This should now be addressed by #26 and #25 .

@Goltergaul
Copy link

@mefellows awesome, do you know when this makes it into a next release?

@YOU54F
Copy link
Member Author

YOU54F commented May 24, 2023

#25 went out two weeks ago, #26 went out this morning as 12.1.0

I noted the GH release tags aren't updated, so raised #27

@mefellows
Copy link
Contributor

Just in case you meant "released to PactFlow", this will happen in the next few days, likely tomorrow.

@mefellows
Copy link
Contributor

I've just tested the above on the latest version (12.1.0) and they all fail validation - which is expected. I think we can close this now?

@YOU54F
Copy link
Member Author

YOU54F commented May 24, 2023

Sounds good Matt and yeah good shout on "released to PactFlow"

We will report back here when this lands in PactFlow, but for now the thread will be closed. If anyone reading has any new issues, please feel free to fill out a new issue :)

@YOU54F YOU54F closed this as completed May 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants