Hi Team, How to add the authentication token in Pr...
# pact-net
d
Hi Team, How to add the authentication token in Provider test cases? PactVerifierConfig was having CustomHeaders property in 3.0 version of PactNet. But the latest version 4.5 is not having this property. Can anyone please help how to use the token generated in Provider testcases with newer version of PactNet.
m
The latest version lets you use a custom header, what have you tried so far?
d
I was trying to use the customheader property like below: var config = new PactVerifierConfig { Outputters = new List<IOutput> { new XUnitOutput(_outputHelper) }, //Custom header CustomHeader = new KeyValuePair<string, string>("testId","test123"), // Output verbose verification logs to the test output Verbose = true }; But it says PactVerifierConfig does not contain a definition for CustomHeader
m
I’d suggest you take a look at the latest API then
d
Yes exactly. Is there any example on how to add this custom header with latest version using .Net?
m
I don’t know, but it looks pretty obvious to me. It’s a method adjacent other very important methods you would have to call . Does this example help? https://github.com/pact-foundation/pact-net/blob/master/samples/OrdersApi/Provider.Tests/ProviderTests.cs#L69 I think it would just be added after
WithHttpEndpoint
d
The latest version of PactNet does not contain the definition for 'WithHttpEndpoint'
m
Which version? It looks like it was added a year ago and should be in the latest 4.x.x and 5.x beta: https://github.com/pact-foundation/pact-net/commit/cc4c5ae48f134728bc87f151d4f7f1f4ef5343ca
You're right that the
WithHttpEndpoint
is not in the latest stable, but I hope you can piece together the rest