One of the common situation that I come across whi...
# general
k
One of the common situation that I come across while talking about the contract testing to my teams is - How to handle the cases where there are intermediator/pass-through services between the
real
consumer and provider for the specific data ? I will try to explain through an example, •
CartService
: is a consumer of these services -
CustomerInformationService
,
ProductCatalogService
and
PricingService
. • For the
CartService.addItemToCart()
operation, It retrieves data from
CustomerInformationService
and
ProductCatalogService
and pass it on to the
PricingService
along with its own data, the current
cart
and
itemToBeAdded
.
PriciningService
uses these combined information to apply the discounts or other free items based on the business rules. • In this case,
CartService
really does not dictate what information it is presented by the
CustomerInformationService
and
ProductCatalogService
and act as pretty much pass-through. Questions are - • How the contracts are supposed to be written by the
CartService
for the information that it depends on other services? • How the collaboration supposed to be happened ? Should
PricingService
be aware about the contract of the
CustomerInformationService
and
ProductCatalogService
? PS: this is my first message in the PACT community after 4 years. I have my own views on the above, but would like to get community views as well.
🙌 1
m
Nice to hear from you!
It's a good question, we have an article on the docs about pass through and downstream systems. But we could do with more on it
k
@Matt (pactflow.io / pact-js / pact-go) , since the since the pass-thru services usually don’t care about the data and often do not validate, the contract testing becomes challenging. One of the option is to validate generically without parsing the payload for specific validation is to have a shared registry for dynamic schemas such as product catalog items and validate the payload against them using the indirection.
m
Yes. We created https://pactflow.io/bi-directional-contract-testing/ in part because of this inconvenience
k
Yes, I am aware the bi-directional contract testing. However, I am think current support is limited to the OpenApi based validation only. What I am referring to dynamic schema for cases like product-catalog above, where different products and business rules are added dynamically without application code changes, and the services involve are implemented using abstractions(like TMF Api as open standards for telecos)
👍 1
May be it’s worth considering a plug-in for schema registries like confluent and apicurio.
👍 1
m
Would be more than open to the idea and seeing where it takes you!