pact-foundation / pact-jvm

JVM version of Pact. Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project.
https://docs.pact.io
Apache License 2.0
1.07k stars 473 forks source link

Provide maven task to create pacticipant #480

Open fitzoh opened 7 years ago

fitzoh commented 7 years ago

As mentioned in #403, when you publish a pact it will fail if either the consumer or producer have not yet been published, and share a name similar to an existing pacticipant.

You can get around this by manually creating a pacticipant with the given name.

A maven task should be added which can perform this pacticipant creation, and the error message should reference this new task when the aforementioned error occurs.

uglyog commented 7 years ago

I would prefer to remove this check from the broker, related issue is https://github.com/pact-foundation/pact_broker/issues/35

fitzoh commented 7 years ago

Ah, I was wondering if that issue existed. Assuming that's made configurable by a query param or something, there should probably be a corresponding flag on the maven/gradle side as well.

I like the idea of manual confirmation when you're creating a "similar" pacticipant, but the cognitive overhead should be lower, such as rerunning the command with -DforceCreation (or something like that) instead of opening confluence, finding the pact page, and updating the curl command with the new pacticipant name (which is what I currently do every time there's a new service).

bethesque commented 7 years ago

Is the publish task not outputing the error text from the response body? The error text has the exact command to run.

fitzoh commented 7 years ago

Just tested it, this is the relevant output I'm seeing

Publishing consumer-producer.json ... FAILED! 409 Conflict - This is the first time a pact has been published for "consumer".
[ERROR] Failed to execute goal au.com.dius:pact-jvm-provider-maven_2.11:3.4.0:publish (default-cli) on project consumer: One or more of the pact files were rejected by the pact broker -> [Help 1]
fitzoh commented 7 years ago

Found the error text... That doesn't address auth, does it? https://github.com/pact-foundation/pact_broker/blob/554c2c6da50f808f3504023c384fae6f35aad229/lib/pact_broker/locale/en.yml#L21

bethesque commented 7 years ago

It looks like the maven code is only outputting the first line of the response body.

No, it doesn't include the basic auth credentials in the curl line (we wouldn't want to put the actual credentials in there), but I can add in an example of what it would look like if you think that would be useful?

fitzoh commented 7 years ago

regarding basic auth: pact-foundation/pact_broker#125