-
-
Notifications
You must be signed in to change notification settings - Fork 349
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
V4InteractionWithCompleteRequest is unimplemented #1224
Comments
Even if we were to implement the You could use the It should be straightforward enough to implement the requested feature though if you're keen to contribute that. As to your actual need:
What we need, possibly, is to support multipart requests with random boundaries. I'm confused by this part of your code though: .withCompleteRequest({
method: "POST",
path: "/upload-file",
headers: {
accept: M.regex(/application\/json/, "application/json"),
"content-type": M.regex(
/^multipart\/form-data.+$/,
`multipart/form-data; boundary=${boundary}`, // <------- do you know the boundary here?
),
},
body: M.regex(/.*/, bodyBuffer.toString("utf-8")),
}) |
That is the example boundary I want to send to the provider. I extracted it into a variable because it's used multiple times for constructing example To be honest, I'm very confused by pact architecture and support roadmap. All language libraries seems to deviate a lot from each other and the zoo of versions (V2/V3/V4) and indirection layers (JS/native/ffi/...) is incomprehensible. Where do I even start? |
Some background on the ecosystem here: https://docs.pact.io/diagrams/ecosystem The spec versions (V2/V3/V4 as you say) relate to the contract file serialisation format and supported features the contract file can model. The FFI is the shared library where the key business logic resides to avoid repeating the effort across 10+ languages (and multiple spec versions). In this case, that particular method you wanted can call the existing FFI methods that are already exposed to Pact JS (example for the V3 interface: https://github.com/pact-foundation/pact-js/blob/master/src/v3/pact.ts#L111-L121). Ultimately, they would just call the same functions that the type-state builder DSL already calls. @rholshausen is there a way to have the mock server match multipart bodies where the boundary name is unknown in advance? I've looked at the fetch API and other common clients and most don't seem to have a way to set them (i.e. they're generated). |
The mock server does not need to know the boundary in advance. As long as the boundary value in the content type header matches that used in the body, it will parse it correctly (i.e. it has to be a correctly formed multipart body). The main issue is that the actual and expected content type headers will have values that don't match. That is why the regex for the header is important. |
The issue is seen in the logs above. The content type header is been treated as different, so the body is not being compared. |
Sorry, that's the point I think - a lot of the HTTP clients don't let you specify the boundary names (they are generated) so you can't specify the |
Normally both the content type header and body is generated. You need to be able to retrieve the header, or get the header to be set. |
I believe that it the problem, because Pact JS DSL requires body content type to be a fixed string and not a RegEx. So I'm not able to specify the content type as a RegEx in both the headers matcher and the body example. |
That's slightly different, I think. The implementation for headers calls a separate FFI method: Lines 163 to 168 in 4d78c65
pactffi_with_header_v2 . This is what sets the matching on the content-type header.
The method you linked to identifies the specific content type on the body, if known (see https://github.com/pact-foundation/pact-reference/blob/efc54d263e7ea53c9511cf389870e790c0158bc3/rust/pact_ffi/src/mock_server/handles.rs#L1861). If you shared a wider log file @shishkin you would likely see the content-type header matching rules setup, along with your regex. @rholshausen correct me if I'm wrong here? |
I'm trying to write a pact for multipart/form-data with file upload. When I use V4 DSL
withRequest
I get body content type mismatch because my test uses random boundary for multipart body. Then I triedwithCompleteRequest
so I can just useregex
matcher for the body. PactJS gives meError: V4InteractionWithCompleteRequest is unimplemented
.Software versions
Issue Checklist
Please confirm the following:
Expected behaviour
There should be a way to relax request matching while still providing a specific example for provider verification.
Actual behaviour
Error: V4InteractionWithCompleteRequest is unimplemented
Steps to reproduce
Relevant log files
The text was updated successfully, but these errors were encountered: