Hi team, Could you point me to more documentation ...
# pact-net
g
Hi team, Could you point me to more documentation on publishing verification results? I've been it this way but I can't seem to get it to work. For most because I'm not sure what this options part is doing. I'm on PactNet v.4.0.0.
Copy code
string version = Environment.GetEnvironmentVariable("VERSION");
        string branch = Environment.GetEnvironmentVariable("BRANCH");
        string buildUri = Environment.GetEnvironmentVariable("BUILD_URL");
        
        verifier.ServiceProvider("My Provider", _fixture.ServerUri)
            .WithPactBrokerSource(new Uri("<https://broker.example.org>"), options =>
            {
                options.ConsumerVersionSelectors(new ConsumerVersionSelector { MainBranch = true, Latest = true })
                    .PublishResults(version, results =>
                    {
                        results.ProviderBranch(branch)
                            .BuildUri(new Uri(buildUri));
                    });
                    .PublishResults(version, results => { results.ProviderBranch(branch);});
            })
            .Verify();
This was my latest error:
Copy code
Failures:

1) Failed to load pact - Could not load pacts from the pact broker '<https://broker.pact.engineering.crxt.io/>' - ContentError("Request to pact broker URL '<https://broker.pact.engineering.crxt.io/pacts/provider/Vehicle%20Financing/for-verification>' failed - HTTP status server error (500 Internal Server Error) for url (<https://broker.pact.engineering.crxt.io/pacts/provider/Vehicle%20Financing/for-verification>)")


There were 1 pact failures

[91m[<http://xUnit.net|xUnit.net> 00:00:02.82]     Financing.Api.ContractTests.FinanceOptionsContractTests.EnsureSomethingApiHonoursPactWithConsumer [FAIL][0m[91m
[0m  Failed Financing.Api.ContractTests.FinanceOptionsContractTests.EnsureSomethingApiHonoursPactWithConsumer [1 s]
  Error Message:
   PactNet.Exceptions.PactFailureException : Pact verification failed
  Stack Trace:
     at PactNet.Verifier.InteropVerifierProvider.Execute()
   at PactNet.Verifier.PactVerifierSource.Verify()
   at Financing.Api.ContractTests.FinanceOptionsContractTests.EnsureSomethingApiHonoursPactWithConsumer() in /src/test/Financing.Api.ContractTests/FinanceContractTests.cs:line 43
  Standard Output Messages:
 Starting verification...
 Pact verification failed
t
Looks like the broker is failing. What version is it running?
I've previously run into issues with provider names that contain spaces - although that was to do with the Ruby CLI, not the broker.
g
Im running:
Copy code
image:
  pactImageRepository: pactfoundation/pact-broker
  pactImageTag: 2.102.1.0
Maybe a good addition is that If I open the url in the error message I get this response in the browser:
g
I see two things missing for options in .WithPactBrokerSource options. Try this:
Copy code
options =>
            {
                options.ConsumerVersionSelectors(new ConsumerVersionSelector { MainBranch = true, Latest = true }
.EnablePending()
.ToeknAuthentication("<your  pact broker authentication token>")
g
Like this:
Copy code
verifier.ServiceProvider("VehicleFinancingService", _fixture.ServerUri)
            .WithPactBrokerSource(new Uri("<https://broker.pact.business.crxt.io>"), options =>
            {
                options.ConsumerVersionSelectors(new ConsumerVersionSelector { MainBranch = true, Latest = true })
                    .EnablePending()
                    .PublishResults(version, results =>
                    {
                        results.ProviderBranch(branch);
                    });
            })
            .Verify();
g
yes, and are you not providing TokenAuthentication to your https://broker.pact.business.crxt.io?
g
No it's ip restricted. But this setup returns the same error. When I remove the
, options =>...
part completely it works and verifies the contract but it doesn't publish the results.
g
you need to provide
options =>...
part to tell to publish the results. this is the code I have, and it works for me. I also have PactNet V 4.0.0
Copy code
pactVerifier
                     .ServiceProvider("ProductService", new Uri(_pactServiceUri))
                       .WithPactBrokerSource(new Uri("<https://domain.pactflow.io>"), options =>
                       {
                           options.EnablePending()
                           .ConsumerVersionSelectors(new ConsumerVersionSelector { Latest=true })
                                  .PublishResults("1.0.0", publish => publish.ProviderBranch("main"))
                                  .TokenAuthentication("<<authtoken>>");
                           
                       })
                    .WithProviderStateUrl(new Uri($"{_pactServiceUri}/provider-states"))
                    .WithRequestTimeout(TimeSpan.FromMinutes(5))
                    .WithSslVerificationDisabled()
                    .Verify()
g
@Ganesh you're a legend. This was it, it works.
👍 2
t
🌮 for @Ganesh!
g
Can I help by adding something to the documentation? I've been looking for three days but the documentation on docs.pact.io mention nothing about publishing verification results
c
Hi Gerard, glad you were able to get things working 🎉. It would be amazing if you would contribute to the docs. The best place to do so in this case would be in the pact net repo, verify provider section looks like the relevant area: https://github.com/pact-foundation/pact-net#verifying-a-provider This is because the notes on publishing verification results are typically located in each of the language specific library's readmes.
🙌 1
t
Oh, cross-posted. Yes, in the .net docs would also be helpful
c
There's is a spot on there where the other ones seem to link through, would be great to connect the dots back to pact-net :)
g
Cool, I'll try to get to it later this week.
🍌 1