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.08k stars 479 forks source link

Pact broker specification has to be added twice if consumer and provider are specified in the same plugin configuration in pom.xml #753

Open amitojduggal opened 6 years ago

amitojduggal commented 6 years ago

Versions used: pact-jvm-consumer-junit_2.11.version = 3.5.20 pact-jvm-provider-junit_2.12.version = 3.5.20 pact-jvm-provider-maven_2.11.version= 3.5.20

Steps to reproduce: I have a service that can act as both the provider as well as the consumer, hence i have added the specifications to the same maven plugin configuration. the problem is, the pact authentication specification has to be specified twice, else i run into a null pointer.

<plugin>
            <groupId>au.com.dius</groupId>
            <artifactId>pact-jvm-provider-maven_2.12</artifactId>
            <version>3.5.20</version>
            <configuration>
                <pactDirectory>target/pacts</pactDirectory> 
                <pactBrokerUrl>xxx</pactBrokerUrl>
                <pactBrokerUsername>xxx</pactBrokerUsername>
                <pactBrokerPassword>xxx</pactBrokerPassword>
                <trimSnapshot>true</trimSnapshot> 
                <tags>
                    <tag>default</tag>
                </tags>
                <serviceProviders>
                    <serviceProvider>
                        <protocol>http</protocol>
                        <host>xxx</host>
                        <port>80</port>
                        <path>xxx</path>
                        <name>xxx</name>
            <pactBroker>
                            <url>xxx</url>
                            <authentication>
                                <username>xxx</username>
                                <password>xxx</password>
                            </authentication>
                            <tags>
                                <tag>default</tag>
                            </tags>
                        </pactBroker>
                    </serviceProvider>
                </serviceProviders>
                <configuration>
                    <pact.showStacktrace>true</pact.showStacktrace>
                    <pact.verifier.publishResults>true</pact.verifier.publishResults>
                </configuration>
            </configuration>
        </plugin>
    </plugins>
</build>

Expected Behaviour:

The specifications should be good to be provided only once . In a microservices environment, there are many situations where the same service can act as both consumer and provider.

uglyog commented 4 years ago

The Maven plugin has been updated (as of version 4.0.6), where the Pact Broker values will default to the top level ones, so they don't have to be repeated.