https://pact.io logo
Join Slack
Powered by
# pact-jvm
  • a

    Ankit Rawat

    03/11/2022, 6:34 PM
    Hi , I am getting below error while running the provider test but the consumer test are successful and pact is published to pact broker. I am using Token mechanism
    u
    m
    • 3
    • 4
  • m

    Mike

    03/15/2022, 12:12 PM
    Hi, 4.1.34 trying to execute provider tests
    Copy code
    @PactDirectory("pact-files")
    @Provider("iPaaS_Stripe")
    @TestInstance(TestInstance.Lifecycle.PER_CLASS)
    class PactStripeProviderTest {
    as a result
    Copy code
    Did not find any PactSource annotations. At least one pact source must be set
    java.lang.UnsupportedOperationException: Did not find any PactSource annotations. At least one pact source must be set
    However, pact is present in pact-files folder. Do you know how to handle this?
    m
    u
    g
    • 4
    • 11
  • j

    Jayachandra K

    03/17/2022, 6:32 AM
    Hey TeamšŸ‘‹, I am trying to publish pact with version using gradle plugin. [au.com.dius.pact:4.1.34] below is the config
    Copy code
    pact {
        publish {
            pactDirectory = "$buildDir/pacts"
            pactBrokerUrl = '<https://pact.sample.com/>'
            pactBrokerUsername = 'username'
            pactBrokerPassword = System.getenv("PACT_PASSWORD")
            version = System.getenv("COMMIT_HASH")
        }
    }
    with this config the project version is affected and changed to the version of
    pact
    I want to keep actual project version
    1.0-SNAPSHOT
    and pact consumer version to
    COMMIT_HASH
    ,. Is it possible or am i missing something here? pact-broker version
    2.94.0.0
    m
    • 2
    • 6
  • p

    PIERRE GERARD

    03/17/2022, 3:23 PM
    Hello All pactflow platypus slack ! I'm pretty new with pact and I'm looking for french speaking users to "build" a french pact community šŸ™‚
    y
    • 2
    • 1
  • s

    Saurabh Goel

    03/24/2022, 10:16 AM
    Hey everyone, we have multiple consumers consuming the same message from provider. The provider verification test classes for all these consumers look absolutely same. the only difference is the @Consumer("consumerName") annotation. It is creating a lot of duplicate code. Is there a way i could declare multiple consumer annotations, or multiple consumers names in the same annotation or reuse the providerverification methods. I tried to re-use the methods by putting them all in a AbstractFile and extending my consumers from it. In this case I start getting the below error:
    Unable to fetch provider method ...
    m
    u
    • 3
    • 7
  • u

    uglyog

    03/29/2022, 2:55 AM
    Is there a proxy in front of your pact broker? Also, look at the debug level logs and you might see what accept headers were sent
    ā˜ļø 1
    m
    • 2
    • 1
  • s

    Serghei Pogodin

    03/30/2022, 8:16 AM
    Hi, I'm using Pact JVM to generate my consumer contracts to further upload them to Pactflow. I'm facing an issue with wildcards usage in matchQuery method. When I'm using
    matchQuery("myQueryParam", ".*")
    it's generating a value which is not supported by Pactflow. Example of generated value:
    "\u095D"
    . Do you think this should be fixed in Pact JVM or Pactflow should be able to handle values like this?
    u
    b
    • 3
    • 12
  • a

    AndrƩ Sousa

    03/30/2022, 4:45 PM
    From the instructions https://github.com/pact-foundation/pact-plugins/tree/main/plugins/protobuf i need to build the plugin and install with Gradle but it will be possible to use this plugin on a java service that uses maven as build tool? btw, the consumer service is Java 8
    m
    u
    • 3
    • 6
  • b

    Ben Eyres

    03/30/2022, 5:44 PM
    Hi all Im trying to create a pact between two services where the request is content-type form-data. With some googling i've found this snippet:
    Copy code
    .withFileUpload("file",
                            "some.json",
                            "multipart/form-data",
                            new byte[]{10,40,61,153,16})
    but what im struggling with is how to add non-file key:values pairs? a curl example would be:
    Copy code
    curl --location --request POST '<http://localhost:8888/v1/some/ep>' \
    --form 'data1="abc"' \
    --form 'data2="def' \ \
    --form 'fileData=@"/some/file_dir/some_file.gz"'
    Can anyone explain how i add
    data1
    and
    data2
    to my pact? Thanks a lot!
    u
    • 2
    • 19
  • j

    Justin Berger

    03/30/2022, 9:23 PM
    Is there a good way to make the consumer side generate v2 spec matchers? I'm generating a spec with (Kotlin, sorry for the weird syntax)
    Copy code
    val pact = ConsumerPactBuilder
       .consumer("Android")
       .pactSpecVersion(PactSpecVersion.V2)
    ...
        .willRespondWith()
        .status(200)
        .body(
            newJsonObject {
                this.`object`("data") { o ->
                    o.integerType("created_at", 1648049202)
                }
            }
        )
    I was hoping that setting it to pact spec 2 it would generate (yeah, it's still not quite v2, but go supports the v3 doc, just not the v3 matchers)
    Copy code
    "$.data.tokens[0].created_at": {
                  "combine": "AND",
                  "matchers": [
                    {
                      "match": "type"
                    }
                  ]
                },
    but instead it's still generating te v3 matcher (which isn't yet supported in go, which is what our producer is written in)
    Copy code
    "$.data.tokens[0].created_at": {
                  "combine": "AND",
                  "matchers": [
                    {
                      "match": "integer"
                    }
                  ]
                },
    u
    • 2
    • 3
  • m

    Michael Branders

    04/01/2022, 1:12 PM
    Hey, I'm just working with the LambdaDSL and if i use a date it expects a java.util.Date and there is no option for a java.time.Localdate . Localdate has replaced Date in java 8 why did you design the new LambdaDSL without Localdate? Is it something that you will add in the lambdaDSL soon? We never use Date anymore in code and to convert Localdate to Date just for pacts, I'm not a fan for that.
    u
    • 2
    • 3
  • a

    Ayush

    04/04/2022, 7:58 AM
    Hey We’re trying to write contract test where the API uses bearer token which expires after a short period If we input the bearer from consumer test then it might get expired when test runs on provider , is there any workaround for that ? somehow we could declare a variable or dummy value which then gets replaced by the newly generated bearer when provider verification tests run ?
    b
    • 2
    • 2
  • s

    shiva kumar velde

    04/04/2022, 11:32 AM
    i would need sample code repo for Messaging PACT
    m
    s
    • 3
    • 7
  • a

    AndrƩ Sousa

    04/04/2022, 4:02 PM
    Also i still have doubts how pact works for messaging cases. On the provider side should i use a MessageTarget pointing to a real kafka topic?
    y
    • 2
    • 4
  • j

    Jason Army

    04/04/2022, 9:05 PM
    Hello. We have a project that's using JDK 8 and trying to do a deploy build with
    classpath 'au.com.dius.pact.provider:gradle:4.2.11'
    in one of the build files and getting this error:
    Copy code
    13:33:09  A problem occurred evaluating project ':dsp-service'.
    13:33:09  > java.lang.UnsupportedClassVersionError: au/com/dius/pact/provider/gradle/PactPlugin has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
    Is there a specific version of the gradle plugin that supports JDK 8?
    m
    • 2
    • 4
  • p

    Prabhakar

    04/06/2022, 12:35 AM
    How do I write PACT contract for { 'idList": [5, 6] } where idList could vary in size I tried
    Copy code
    DslPart requestBody = LambdaDsl.newJsonBody((o) -> {
      o.array("idList", (arr)-> {
         arr.numberType(6);
    });
    This would work if I am passing only one value. If more than value need to be in the list then I have to add something like this...
    Copy code
    arr.numberType(6).numberType(7);
    How can this be made generalized (like minArrayLike) so that one or more could be passed and contract is still valid
    m
    b
    u
    • 4
    • 17
  • b

    Ben Eyres

    04/06/2022, 6:08 AM
    I'm trying to publish pact using the maven plugin available. Reading these docs: https://docs.pact.io/implementation_guides/jvm/provider/maven#configured-as-jvm-system-properties But im unable to set the consumer version. Ive tried
    Copy code
    mvn pact:publish -Dpact.publish.consumer.version=0.2-SNAPSHOT
    export PACT_PUBLISH_CONSUMER_VERSION=0.2-SNAPSHOT
    Neither seem to work. Im getting the following error from the plugin when running
    mvn pact:publish
    Copy code
    Cannot change the content of the pact for Producer version 0.1-SNAPSHOT and provider Producer, as race conditions will cause unreliable results for can-i-deploy. Each pact must be published with a unique consumer version number
    Can anyone tell me how i can increment the consumer version of the pact?
    u
    m
    • 3
    • 12
  • g

    Gokul Menon

    04/06/2022, 9:49 AM
    Hello Everyone , Good day ! I was wondering if someone have tested message queues with pact , I found this official documentation but if there is someone have any real time experience , I would like to connect to know a bit deep about the same , please leave a message šŸ™‚ Thanks In advance šŸš€
    m
    s
    • 3
    • 5
  • d

    Deepesh Gupta

    04/07/2022, 1:34 PM
    Hey, i was wondering, is there any way by which i can hide tokens(be it authToken/APIToken) while a pact is generated, i can see that these sensitive values are visible in an interaction. Is it possible to hide these sensitive attributes?
    m
    • 2
    • 3
  • m

    Michael Branders

    04/08/2022, 8:40 AM
    How can you describe in DSL a map?
    Copy code
    @Getter
    @ToString
    @Builder(toBuilder = true)
    @Jacksonized
    @JsonIgnoreProperties(ignoreUnknown = true)
    public class ObjectDto {
    
        private final String id;
        private final Map<Locale, String> descriptions;
    
    }
    I need to get that map in DSL
    Copy code
    private DslPart objectDtoContract() {
        return newJsonBody((o)->{
            o.stringMatcher("id", REGEX_ID, OBJECT_ID);
            o.array("description",(map)->{
                ????
            });
        }).build();
    }
    Dont realy find any examples on how to get a map in a DslPart
    u
    b
    • 3
    • 6
  • c

    Carl Ha

    04/11/2022, 10:53 AM
    Hello everyone! We currently have the problem that we have different providers test classes (for on one contract) located in different modules and therefore in different jvm's when running the tests. Therefore the provider sdk has no way of knowing when all interactions of the contract were validated and therefore never ends up publishing to the pact broker. Is there any existing solution to go about this? (Repost from General chat)
    f
    b
    • 3
    • 6
  • s

    Songqing

    04/12/2022, 12:30 AM
    Hello there! may I check vendor related information? who runs OSS, DiUS? who runs SaaS, Pactflow/SmartBear?
    u
    • 2
    • 4
  • a

    Alessandro

    04/12/2022, 2:03 PM
    Hi all, we have a custom test harness that I would like to embed the pact verification in. We have our own custom http client already configured, so I would like to be able to use the verification on a slightly different level. What would be the best way to plug in the verification of pacts with responses? (On the JVM)
    u
    • 2
    • 5
  • n

    Nathan Deamer

    04/12/2022, 5:21 PM
    pact.verifier.buildUrl
    - Should I be able to see this in pactflow anywhere? I am using
    id '<http://au.com|au.com>.dius.pact' version '4.3.5'
    gradle plugin. https://github.com/pact-foundation/pact-jvm/blob/master/provider/junit/README.md#setting-the-build-url-for-verification-results-4216432
    u
    • 2
    • 2
  • j

    James P

    04/13/2022, 4:44 PM
    Hi, out of interest does the PactDslWithProvider
    query
    parameter url encode the variables it is sent? I have a service which sends a uri encoded value to another service
    "from=2022-04-11T09%3A52%3A59%2B0100"
    as a query parameter in the path. If I try and do a comparison using this value then it fails with an unexpected request error. However, if I wrap the query parameter in a uri decode statement then the request matches. When I send the http request, I just enter the value specified and thats enough to match. UPDATE: I've just found the
    encodedQuery
    param which has sorted out me having to encode the query, however the json I have generated does not have the encoded version
    u
    • 2
    • 5
  • p

    Pavlo Sprogis

    04/14/2022, 1:55 PM
    hi guys, I want to try using Pactflow, I have updated provider tests configuration (host, scheme and token) but now test fails with the following errors:
    Copy code
    ERROR [15:45:47] [main] a.c.d.p.c.p.HalClient          Failed to fetch the root HAL document
    javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    	at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:131)
    ...
    is there a way to fix this (on my laptop and during CI build) ?
    y
    s
    • 3
    • 14
  • f

    Francislainy Campos

    04/18/2022, 6:42 AM
    Hi, is it possible to inject dynamic ids for parts of the body rather than only the path or query from provider state such as in here https://pactflow.io/blog/injecting-values-from-provider-states/? Thank you.
    j
    • 2
    • 5
  • a

    Aurelia

    04/20/2022, 1:53 PM
    Hello, I a Java project using pact junit5 4.2.11, and I have encoding issues. When generating a Pact, the response body is read from a json file containing accented characters (Ć©, ĆØ, ü, etc) When the pact is generated, those characters are replaced with their unicode encoding. Then on the producer side, when running the test, the pact verification fails due to those encoded characters. Do you know why the pact can’t just be written with the unicode characters ? I found nothing helpful when searching on Internet, but I’m surely not the only person with accented characters in the pact payload. Thanks in advance for your help šŸ™
    u
    • 2
    • 6
  • y

    yusei ygui

    04/20/2022, 8:45 PM
    Hello, new to Pact. Was wondering if we can use pact to test pagination?
    u
    b
    • 3
    • 6
  • d

    Dennis Woditsch

    04/21/2022, 12:23 PM
    Hey šŸ‘‹šŸ» Unfortunately I did not found any information about my current problem. So we have successfully integrated PACT between two (asynchronous) services. Basically all the pieces are tight together, last part I was working on was integrating web hooks whenever a contract changed that
    required
    verification. To come to the question: We saw that PACT verified several versions - especially from PR's which actually might not exist anymore at this time. I think it would make most sense to just verify against deployed versions of a service right? Basically latest master/main would be fine + all versions deployed on environments (recorded deployments). Is there some configuration available? Here is my current (provider) test setup
    Copy code
    @Provider("goto-conference-service")
    @PactBroker
    @SpringBootTest
    @Import(KafkaConsumerConfiguration.class)
    @AutoConfigureMockMvc
    @AllowOverridePactUrl
    public class ConferenceEventsContractTests extends TestcontainersIntegrationTests {
    
        @Autowired
        private MockMvc mockMvc;
    
        @Autowired
        private ObjectMapper objectMapper;
    
        @TestTemplate
        @ExtendWith(PactVerificationInvocationContextProvider.class)
        void testTemplate(Pact pact, Interaction interaction, PactVerificationContext context) {
            context.verifyInteraction();
        }
    
        @BeforeAll
        static void beforeAll(){
            PactBrokerDefaults.initFallbackTokenIfMissing();
            PactBrokerDefaults.initFallbackUrlIfMissing();
        }
    
        @BeforeEach
        void before(PactVerificationContext context) {
            context.setTarget(new MessageTestTarget());
        }
    
        @PactVerifyProvider("valid conference created event")
        public String verifyConferenceCreatedEvent() throws Exception {
            ConferenceEvent createdEvent = getEventByCreateTrigger(event -> "ConferenceCreated".equals(event.getEventName()));
            return objectMapper.writeValueAsString(createdEvent);
        }
        
        // some more not relevant pieces of code
    }
    s
    • 2
    • 12
12345...14Latest