Hi all,
I am trying to test a scenario where the request contains Multipart/Form-Data.
This of-course is not a standard JSON and it is not supported by Pact.
However, does anyone have any suggestion on how to test this via pact?
The data being send looks like:
------WebKitFormBoundaryAo5ACaMXzKRL2lFA
Content-Disposition: form-data; name="file"; filename="AResume.txt"
Content-Type: text/plain
My resume
------WebKitFormBoundaryAo5ACaMXzKRL2lFA--
The two problems with the above is:
1) Send this as part of pact
2) Mock server matching the request to what we program it with due to the dynamic values of the Boundary
I thought of one approach which is a bit complicated is to specify the Boundary in the header:
headers: {
'Content-Type': 'multipart/form-data; boundary="test"'
}
Then specify the body to be
------test
Content-Disposition: form-data; name="file"; filename="AResume.txt"
Content-Type: text/plain
My resume
------test
Then when the request is being send to the mock server, intercept it and replace:
------WebKitFormBoundaryAo5ACaMXzKRL2lFA
with
------test
This will get a bit more complex when dealing with .doc, .pdf, .etc and doesn't really feel right.
There possibly is a simpler solution.
I appreciate your thoughts.
Thanks.
Behdad.