-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Message verification support #11
Comments
Also need to consider provider-state support: https://docs.pact.io/implementation_guides/jvm/provider#provider-state -- it looks like currently this works by:
|
It doesn't seem like there is any easy alternative to having test-only HTTP endpoints on the provider application for provider states. |
After playing around a bit, I think it would be possible to not use annotations, but it would probably require some refactoring of the |
Well this is a bummer pact-foundation/pact-jvm#610 -- I was wondering what would happen if I re-used the same producer/consumer names for both request/response and message pacts... that's the answer
|
Issue #11: allow verification by annotated method
@jbwheatley I've opened pact-foundation/pact-jvm#1379 in class ProviderPactMessageVerificationSpec extends PactVerifier with DecorateAsJava {
def provider: ProviderInfoBuilder = ProviderInfoBuilder(
"provider",
"http",
"localhost",
3456,
"/",
PactVerification.FUNCTION,
FileSource("consumer", new File(getClass.getClassLoader.getResource("consumer_provider.json").getPath))
)
def messages: String => MessageAndMetadata = {
case "Resource with name 'example'" =>
val headers = Map("header-name" -> "header-value")
val payload = """{"hello":"world"}""".getBytes
new MessageAndMetadata(payload, headers.asJava)
}
verifyPacts()
} |
Just wanted to start a discussion here about the best way to implement message verification support in Scala. First, a quick overview of current state:
there is a
PactVerifier
trait which works without any modification for request/response pactsthe trait uses
ProviderVerifier().runVerificationForConsumer
which supports both message and interaction (request/response) pactscurrently this method always defaults to request/response verification because
ProviderInfo
doesn't have an explicitverificationType
-- it is easy to add support for this to theProviderInfoBuilder
:however, this will result in verification via annotation (
@PactVerifyProvider("message description")
):Full example:
There are a few things awkward about this flow:
ProviderInfoBuilder
should probably make defining the provider HTTP information optional -- it could be awkward for message verification where no provider states are needed (otherwise the HTTP information would be used to make requests against the provider application for states)So what kind of test DSL do we want for linking of pact messages to message generators? And how would we integrate that with
pact-jvm
? Under the hood, theProviderVerifier
eventually calls verifyMessage -- we could invoke this directly ourselves. I think in general we should try not to drift too far from thepact-jvm
implementation.Another option I have seen is requesting of messages via an HTTP proxy: https://github.com/pact-foundation/pact-message-demo (the gist: you add endpoints to the provider to support returning messages based on description and provider state) -- however,
pact-jvm
does not support this natively.The text was updated successfully, but these errors were encountered: