question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New verification type: FUNCTION

See original GitHub issue

Currently there exist two verification types:

  • PactVerification.REQUEST_RESPONSE – verifies an HTTP response from a request
  • PactVerification.ANNOTATED_METHOD – can be used to verify either an HTTP response, or a message and metadata

I would like to propose a third verification type, PactVerification.FUNCTION, which would be similar to PactVerification.ANNOTATED_METHOD except that:

  • only a single function is required, it would be a factory of String -> Any (but really, it would return specific types that the library already understands, like MessageAndMetadata).
  • the function would be provided explicitly to ProviderVerifier instead of via scanning the classpath for annotated methods
  • the function would not be invoked by reflection (e.g. java.lang.reflect.Method.invoke()), it would just be called normally like any other callback method in the ProviderVerifier. this means the method scope would be the same as any method in the test class instead of having to provide a specific instance for invocation.

This could be used for both messages and request/response, although the return types would need to vary depending on the interaction type. Probably the return value can be the same as the return values that are currently supported by the PactVerification.ANNOTATED_METHOD type.

My guess is the easiest way to implement this is to have another bifurcation in ProviderVerifier.verifyInteraction which would call a different method if the verification type is FUNCTION, for example verifyResponseByFunction, and define a new property on the ProviderVerifier that would contain the available function to call (verificationFunction: Function<String, Any>, or something like that). There can probably be some refactoring around verifyResponseByInvokingProviderMethods and verifyMessage to split common functionality into common methods, since mostly the only change is how to call the method and get the return value.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
solarmosaic-kflorencecommented, Jun 10, 2021

I am hoping we can apply this change first to the underlying Provider library before we need to implement it in all the other places, if that’s possible.

0reactions
uglyogcommented, Aug 22, 2021

4.1.25 released

Read more comments on GitHub >

github_iconTop Results From Across the Web

function new() with virtual keyword | Verification Academy
We implement constructor function new() in each class. Its defined as function with no return type. Why cant we specify it as virtual...
Read more >
Type-based formal verification - Alejandro Serrano - YouTube
This talk provides an introduction to dependent and refinement types, and how they fit in the larger realm of formal verification.
Read more >
What is the function of Use Verification code form App or Token
Verification codes, on the other hand, are one-time-use, short-lived codes that are sent by email or SMS when the user logs in through...
Read more >
Verify that functions were called | Mocking | MockK Guidebook
Inside the verification block (between the opening curly bracket { and closing curly bracket } ), you write the method you want to...
Read more >
What is Two-Factor Authentication (2FA) and How Does It Work?
Two-factor authentication adds an extra layer of security to identity and access ... SFA as they both belong to the knowledge authentication factor...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found