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

Verification result incorrectly reports "Pact-Rust" as verifying implementation when using Golang provider verification #499

Open
FabianRolfMatthiasNoll opened this issue Feb 3, 2025 · 2 comments

Comments

@FabianRolfMatthiasNoll
Copy link

Description:

When verifying a provider using our Golang implementation and submitting the results to the Pact Broker (hosted via the official Docker image), the verification metadata in the broker incorrectly shows that the pacts were verified by "Pact-Rust" (version "1.2.5"). This behavior is unexpected, as our tests use a Golang verification tool.

Inside the pactBroker log the verification is published and instead of the pact-go package with the version 2.2.0 the pact-rust package is mentioned.

{
  "providerName": "MQTTProducer",
  "providerApplicationVersion": "1.0.0",
  "success": true,
  "verificationDate": "2025-02-03T05:54:37+00:00",
  "testResults": [
    {
      "interactionId": "4502629169ea07b9fd7c9fd70c772553a1b4407d",
      "success": true
    }
  ],
  "verifiedBy": {
    "implementation": "Pact-Rust",
    "version": "1.2.5"
  },
  "_links": {
    "self": {
      "title": "Verification result",
      "name": "Verification result 201 for Pact between MQTTConsumer (1.0.1) and MQTTProducer",
      "href": "http://localhost:9292/pacts/provider/MQTTProducer/consumer/MQTTConsumer/pact-version/cd421621766dde56e9e01a0c8a8b47c4b5f63b40/verification-results/201"
    },
    "pb:pact-version": {
      "title": "Pact",
      "name": "Pact between MQTTConsumer (1.0.1) and MQTTProducer",
      "href": "http://localhost:9292/pacts/provider/MQTTProducer/consumer/MQTTConsumer/pact-version/cd421621766dde56e9e01a0c8a8b47c4b5f63b40/metadata/Y3ZuPTEuMC4x"
    },
    "pb:triggered-webhooks": {
      "title": "Webhooks triggered by the publication of this verification result",
      "href": "http://localhost:9292/pacts/provider/MQTTProducer/consumer/MQTTConsumer/pact-version/cd421621766dde56e9e01a0c8a8b47c4b5f63b40/verification-results/201/triggered-webhooks"
    }
  }
}
@YOU54F
Copy link
Member

YOU54F commented Feb 12, 2025

The pact-go, and other client libraries use pact-rust under the hood via FFI.

It is possible to configure the verifier with a specific name and application version, which we are actually setting in pact-go

handle: native.NewVerifier("pact-go", command.Version),

however this is not used in the verifier code in rust, which defaults to Pact-Rust and the current version of the shared library in use.

https://github.com/pact-foundation/pact-reference/blob/cb06065945ff5f8bb1c6a6e59ad6266d470a4e99/rust/pact_verifier/src/pact_broker.rs#L855

So to solve this, the pact_verifier rust code, should take into consideration, the calling_app.

https://github.com/pact-foundation/pact-reference/blob/cb06065945ff5f8bb1c6a6e59ad6266d470a4e99/rust/pact_ffi/src/verifier/handle.rs#L60

if the calling_app is None, then it should default to the current Pact-Rust

@YOU54F
Copy link
Member

YOU54F commented Feb 12, 2025

Ahh okay, this has been addressed in the pact-rust codebase by adding a new key to the payload sent to the pact-broker

related issue - pact-foundation/pact-reference#307

example payload

https://github.com/pact-foundation/pact-reference/blob/2b5148b984fbdc25c1da66fd3ef5041f313f2162/rust/pact_verifier/src/pact_broker.rs#L2224-L2232

      "verifiedBy": {
        "implementation": "Pact-Rust",
        "version": VERIFIER_VERSION,
        "clientLanguage": {
          "testFramework": "TEST",
          "name": "TESTER",
          "version": "1.2.3"
        }
      }

Here are the docs for the pact broker publish verification endpoint

https://github.com/pact-foundation/pact_broker/blob/master/lib/pact_broker/doc/views/pact/publish-verification-results.markdown

The API decorator, isn't setup to display this extra detail

https://github.com/pact-foundation/pact_broker/blob/master/lib/pact_broker/api/decorators/verification_decorator.rb#L12-L21

        property :provider_name, as: :providerName, writeable: false
        property :provider_version_number, as: :providerApplicationVersion, writeable: false
        property :success
        property :execution_date, as: :verificationDate
        property :build_url, as: :buildUrl
        property :test_results, as: :testResults
        nested :verifiedBy do
          property :verified_by_implementation, as: :implementation
          property :verified_by_version, as: :version
        end

and would need to support the extra keys

verifiedBy.clientLanguage.testFramework
verifiedBy.clientLanguage.name
verifiedBy.clientLanguage.version

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

2 participants