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

Query parameters aren't failing the verify method for a consumer #40

Open
lirantal opened this issue Aug 19, 2017 · 2 comments
Open

Query parameters aren't failing the verify method for a consumer #40

lirantal opened this issue Aug 19, 2017 · 2 comments

Comments

@lirantal
Copy link

Original discussion from gitter with @bethesque asking to track it here:

@lirantal the detailed logic for what matches and doesn't match can be found in the pact specification. The ruby impl is up to v2 https://github.com/pact-foundation/pact-specification/tree/version-2/testcases/request
I'm a bit suspicious about that params anomaly you mentioned earlier. Can you raise an issue in the pact-support repository please?

This is reproduced on:

  • Mac OS
  • Node.js v7.10
  • Pact JavaScript npm library 2.6.0

To reproduce:

  1. Setup an interaction where the query parameters are omitted from the request interaction
  2. Make an actual request with query parameters
  3. pact.verify() doesn't throw an error
@bethesque
Copy link
Member

@uglyog do you know what the behaviour is for jvm/rust?

@YOU54F
Copy link
Member

YOU54F commented Aug 15, 2024

The rust core when utilised via FFI will fail in this scenario

require 'pact/ffi'
require 'pact/ffi/logger'
require 'pact/ffi/mock_server'
require 'pact/ffi/http_consumer'
require 'pact/ffi/utils'
require 'json'
require 'httparty'

PactFfi::Logger::log_to_stdout(5);
@pact = PactFfi::HttpConsumer::new_pact("V4-consumer","V4-provider");
@interaction = PactFfi::HttpConsumer::new_interaction(@pact, "interaction for a consumer test")
PactFfi::HttpConsumer.with_specification(@pact, PactFfi::FfiSpecificationVersion['SPECIFICATION_VERSION_V2'])
@mock_server_port = PactFfi::MockServer.create_for_transport(@pact, '127.0.0.1', 0, "http", nil)
response = HTTParty.get("http://127.0.0.1:#{@mock_server_port}/?name=ron&status=good")
puts response
matched = PactFfi::MockServer::matched(@mock_server_port)
puts matched
mismatches = PactFfi::MockServer::mismatches(@mock_server_port)
puts mismatches

which returns the mismatch

[
  {
    "method": "GET",
    "mismatches": [
      {
        "actual": "[\"good\"]",
        "expected": "",
        "mismatch": "Unexpected query parameter 'status' received",
        "parameter": "status",
        "type": "QueryMismatch"
      },
      {
        "actual": "[\"ron\"]",
        "expected": "",
        "mismatch": "Unexpected query parameter 'name' received",
        "parameter": "name",
        "type": "QueryMismatch"
      }
    ],
    "path": "/",
    "type": "request-mismatch"
  }
]

however the ruby core does appear to exhibit the behaviour where additional query params in the consumer request are not considered when ascertaining if a correct request as per the users expectations (not specifying query params should enforce that it only matches incoming requests which do not have query params)

https://github.com/pact-foundation/pact-ruby-e2e-example/tree/pact-support-issue-40

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