Marcin Baranowski
09/23/2021, 10:53 AMInvalid pact broker host specified ('${pactbroker.host:}'). Please provide a valid host or specify the system property 'pactbroker.host'.
java.lang.IllegalArgumentException: Invalid pact broker host specified ('${pactbroker.host:}'). Please provide a valid host or specify the system property 'pactbroker.host'.
My application.yaml has:
pactbroker:
host: "<https://valid-host>"
port: 443
protocol: "https"
auth:
token: "tokenValue"
I use gradle and my only pact dep is:
testImplementation("au.com.dius.pact.provider:junit5spring:4.2.11")
My Test:
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@Provider("provider")
@PactBroker
public class PactTest extends AbstractIntegrationTest {
@LocalServerPort int port;
@Value("${pactbroker.host}")
String host;
@BeforeEach
public void setupTestTarget(PactVerificationContext context) {
System.out.println("host");
System.out.println(host);
context.setTarget(new HttpTestTarget("localhost", port));
}
@TestTemplate
@ExtendWith(PactVerificationSpringProvider.class)
public void pactVerificationTestTemplate(PactVerificationContext context) {
context.verifyInteraction();
}
}
Host value is assigned correctly in test file.
Why Pact doesn't see these values? What should I change?Michael Branders
01/21/2022, 1:49 PMShan
01/28/2022, 2:42 AMjunit5spring
from 4.1.16
to 4.2.0
, the problem is test hangs like 20s in certain tests. When I revert back my version to 4.1.16
or 4.1.19
it runs smoothly. Any idea why this is happening?extra 2
02/07/2022, 9:35 PMAnna Khvorostianova
02/08/2022, 12:22 PMPavlo Sprogis
02/08/2022, 9:33 PMContent-Type
header in generated pact json during consumer tests, e.g.:
"headers": {
"Content-Type": "application/json; charset=UTF-8"
},
even though I do not mention this header explicitly. Is it possible to configure pact to skip content-type header and do not record it in generated pact json? Or omit content-type during pact verification tests in provider?
I’m using <http://au.com|au.com>.dius.pact.consumer.junit5 4.2.17
for consumer tests and <http://au.com|au.com>.dius.pact.provider.junit 4.1.17
for provider testsChristoph Oswald
02/09/2022, 12:47 PMAjay Kawde
02/10/2022, 9:53 AMManuGu
02/11/2022, 3:26 PMAjay Kawde
02/14/2022, 8:21 AMMike
02/17/2022, 9:56 AM@PactBroker(
authentication= @PactBrokerAuth(username = "", password = ""),
port="8080",
consumerVersionSelectors={ @VersionSelector(latest = "true") }
)
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class PactCPEProviderTest {
I take it from Docs https://docs.pact.io/pact_broker/advanced_topics/consumer_version_selectors/
But compiler argues on VersionSelector with
An annotation can't be used as the annotations argument
Is it possible to solve it somehow?Ajay Kawde
02/17/2022, 11:10 AMGuillermo
02/17/2022, 8:12 PMeachLike
only works when an array has the same object in each index.
Here is an example JSON that needs to be matched :
{
"version": 1234,
"data": [
{
"name": "someName"
},
{
"name": "anotherName",
"id": 131312
}
]
}
As you see using an eachLike on data wouldn't work because of the extra id
field. Does anyone know how I can achieve this? I've look at the documentation, but I can't seem to figure it out. Thanks!André Sousa
02/22/2022, 2:12 PMAndré Sousa
02/28/2022, 2:41 PMMatt (pactflow.io / pact-js / pact-go)
Ayush
03/01/2022, 3:57 AMMatt (pactflow.io / pact-js / pact-go)
Thomas K
03/01/2022, 10:40 PMMatt (pactflow.io / pact-js / pact-go)
Rejeesh Gangadharan
03/02/2022, 9:19 AMThomas K
03/02/2022, 12:00 PMAuthorization
header where the value is a JWT. For it to be accepted fine by the provider, it needs to not be expired etc. Is there any way I can handle this with matchers etc? I have this regex
.matchHeader("Authorization", "^[A-Za-z0-9-_=]+\\.[A-Za-z0-9-_=]+\\.?[A-Za-z0-9-_.+/=]*\$")
but not sure about the JWT expiry part and obviously how the jwt would be decoded from that regex?andrewhiles
03/02/2022, 5:05 PMAbhay Tamboli
03/03/2022, 12:35 AMThomas K
03/03/2022, 12:23 PMbuilder.given()...
) no longer is applied in the same way in V4 ? looking for example for setting consumer side expectationsReuben Tonna
03/04/2022, 2:45 PMfinal DslPart body = newJsonBody(root -> {
root.stringMatcher("callCount", "\\d+", "10");
root.unorderedMinArray("distribution", 0, item -> item.object(o -> {
o.stringMatcher("id", "\\d+", "1");
o.stringMatcher("callCount", "\\d+", "10");
}));
}).build();
return builder
.usingLegacyMessageDsl()
.given("non-empty-greeting-usage-statistics")
.expectsToReceive("private.metrics.greeting.usage")
.withContent(body)
.toPact(V4Pact.class);
My intent is to state that this consumer accepts message content of the general shape { callCount: x, distribution: [] } where distribution array can be empty, and if not empty the items must match the general structure { id: x, callCount: y }. The pact generates and is loaded in the broker. However when in my provider I return payloads such as:
"{\"callCount\":\"0\",\"distribution\":[]}";
It is failing with:
1) private.metrics.greeting.usage: generates a message which has a matching body
1.1) body: $.distribution Expected [{"callCount":"10","id":"1"}] to match [] ignoring order of elements
[
- {
- "callCount": "10",
- "id": "1"
- }
+
]
Any thoughts what I am missing? Maybe my expectation that in one pact I can define both scenarios were the array have items matching the example, or have no items is incorrect. Thoughts?Harihara Raj LK
03/05/2022, 1:22 PMThomas K
03/07/2022, 11:29 AMAnkit Rawat
03/07/2022, 8:05 PMgesellix
03/08/2022, 1:20 PMfor pacticpant in "${pacticipants}"
do
pact-cli broker create-version-tag --pacticipant="${pacticipant}" --version="${version}" --tag=${tag}
done
Is there a simpler way of tagging every pacticipant in a Maven project or at least collecting the list of pacticipants?