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

Matchers: Include matcher in query parameters failing to match #485

Open
surpher opened this issue Jan 28, 2025 · 0 comments
Open

Matchers: Include matcher in query parameters failing to match #485

surpher opened this issue Jan 28, 2025 · 0 comments
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@surpher
Copy link

surpher commented Jan 28, 2025

🌎 Environment

  • Platform: pact_ffi
  • Version/Release: 0.4.25
  • Pact spec: v3, v4
  • FFI used:
bool pactffi_with_query_parameter_v2(
 InteractionHandle interaction, 
 const char *name, 
 size_t index, 
 const char *value
);

💬 Description

Setting up unit tests for PactSwift verifying various query parameter usage for Include matcher type.

QueryMismatch: Unable to match ["sub"] using Include("sub")
  Expected: ["sub"]
  Actual: ["substring"]
  Parameter: $.item])"

🦶 Reproduction Steps

Steps to reproduce the behaviour:

  1. Setup a pact interaction that expects a query parameter,
  2. Set query parameter with string value that would include the substring defined in ‘Include’ matcher,
  3. Set query parameter’s matching rule "{\"pact:matcher:type\":\"include\",\"value\":\"sub\"}"
  4. Trigger GET /endpoint?item=substring,
  5. Verify pact interaction.

🤔 Expected Results

Pact test should succeed when GET request’s query parameters’ value contains the substring defined in Include matcher.

😲 Actual Results

Pact test fails stating:

QueryMismatch: Unable to match ["sub"] using Include("sub")
  Expected: ["sub"]
  Actual: ["substring"]
  Parameter: $.item])"

🌳 Logs

...
RefCell { 
  value: PactHandleInner { 
    pact: V4Pact { 
      consumer: Consumer { name: "Consumer" }, 
      provider: Provider { name: "Provider" }, 
      interactions: [
        SynchronousHttp { 
          id: None, 
          key: None, 
          description: "an interaction with query item matcher 'includes'", 
          provider_states: [], 
          request: HttpRequest { 
            method: "GET", 
            path: "/interaction", 
            query: Some({"item": [Some("sub")]}), 
            headers: None, 
            body: Missing, 
            matching_rules: MatchingRules { 
              rules: {
                PATH: MatchingRuleCategory { name: PATH, rules: {} }, 
                QUERY: MatchingRuleCategory { name: QUERY, rules: {
                  DocPath { 
                    path_tokens: [Root, Field("item")], 
                    expr: "$.item" 
                  }: 
                  RuleList { 
                    rules: [Include("sub")], 
                    rule_logic: And, 
                    cascaded: false 
                  }
                } 
              }
            } 
          }, 
          generators: Generators { categories: {} } }, 
          response: HttpResponse { 
            status: 200, 
            headers: None, 
            body: Missing, 
            matching_rules: MatchingRules { rules: {} }, 
            generators: Generators { categories: {} } }, 
            comments: {}, 
            pending: false, 
            plugin_config: {}, 
            interaction_markup: InteractionMarkup { markup: "", markup_type: "" }, 
            transport: None 
          }
        ], 
      metadata: {
        "namespace1": Object {"name1": String("value1")}, 
        "namespace2": Object {"name2": String("value2")}, 
        "pactRust": Object {"ffi": String("0.4.25")}
      }, 
      plugin_data: [] 
    }, 
    mock_server_started: true, 
    specification_version: V4 
  } 
}

...
----------------------------------------------------------------------------------------
       method: GET
       path: /interaction
       query: Some({"item": [Some("substring")]})
       headers: Some({"accept-language": ["en-AU", "en;q=0.9"], "user-agent": ["xctest/23600 CFNetwork/1568.300.101 Darwin/24.2.0"], "host": ["127.0.0.1:4658"], "accept-encoding": ["gzip", "deflate"], "connection": ["keep-alive"], "accept": ["*/*"]})
       body: Empty
----------------------------------------------------------------------------------------
...

QueryMismatch: Unable to match ["sub"] using Include("sub")
  Expected: ["sub"]
  Actual: ["substring"]
  Parameter: $.item])"

...

📄 Stack Traces

See attached query-param-include-matcher-issue.log for full standardOut: .trace log:

query-param-include-matcher-issue.log

🤝 Relationships

  • Related PRs or Issues:
@rholshausen rholshausen added the bug Indicates an unexpected problem or unintended behavior label Jan 29, 2025
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

2 participants