Hello all :slightly_smiling_face: My team is looki...
# pact-jvm
c
Hello all 🙂 My team is looking at a very specific use case and we are trying to figure out if Pact is the right tool for us, so I was wanting to check if someone may have used it successfully in a similar scenario: • Consumer (written in TS) that is a user facing application (to do with management of user accounts). This sends requests to a backend API when needing to update user details (e.g. update phone number) • Provider (Java, thus posting here). Accepts requests and interact with the database with user details Consumer tests are implemented in we can generate a Pact file, but we have a couple of sticking point with the provider side • We cannot run the api locally, thus we are considering running the tests against a deployed version of the API (in a test env) • The deployed API has an authentication layer, making it very hard to set up the request properly in a test file (as we would need to generate an auth token on the fly, using an OAuth2 auth flow, and then use this to modify the request as set out in the pact file) Anyone has come across a similar use case before? Apologies for the very long post, any help/pointes/thoughts massively appreciated 😄 as a bonus: I have been wondering if there is any way to create a custom class implementing the TestTarget interface, which instead of forwarding requests to a host/port it directly calls handler method in the test base - but unsure if this is even in realm of possibilities
j
We cannot run the api locally, thus we are considering running the tests against a deployed version of the API (in a test env)
As long as you trust this environment that should be doable. However, the tradeoff is isolation and control over the environment. Considering contract tests executed as a part of consumer build pipeline, it might get cumbersome when multiple consumer pipelines will act on the same test environment. The state of provider service might change during the test execution and the flakiness might happen, failing the consumer build.
The deployed API has an authentication layer, making it very hard to set up the request properly in a test file
read up on request filters - it should help
🙌 2
thanks 1
m
Lovely answer! 🌮 for you @Jan Królikowski
🙌 1
d
Copy code
We cannot run the api locally
I think I would try to solve this challenge, before I went down any other paths. There are so many development velocity benefits to being able to spin up a reduced version of a service locally, even if you have to mock out the database or mock out the authentication provider to do so.
💯 1