Skip to content

Commit

Permalink
test showing the default mediatypes of multipart forms when they are …
Browse files Browse the repository at this point in the history
…no set explicitly
  • Loading branch information
ryber committed Feb 18, 2024
1 parent 1043281 commit 48beed0
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -449,4 +449,31 @@ void mediaTypesForParts() {
});

}

@Test
void defaultMediaTypes() {
Unirest.post(MockServer.POST)
.field("content", rezInput("/spidey.pdf"), "spiderman")
.field("metadata", "{\"foo\": 1}")
.asObject(RequestCapture.class)
.getBody()
.assertHeader("Content-Type", h -> {
h.assertMainValue("multipart/form-data");
h.assertHasParam("boundary");
h.assertParam("charset", "UTF-8");
// Lets create a way to tell unirest what the boundary should be so we can test it easier.
//h.assertRawValue("multipart/form-data; boundary=4ebf68bc-70f8-462b-b3a5-48dadb236af3;charset=UTF-8");
})
.assertBodyPart("content", p -> {
p.assertFileName("spiderman");
p.assertContentType("application/octet-stream");
p.assertContentDisposition("form-data; name=\"content\"; filename=\"spiderman\"");
})
.assertBodyPart("metadata", p -> {
p.assertBody("{\"foo\": 1}");
p.assertContentType("application/x-www-form-urlencoded; charset=UTF-8");
p.assertContentDisposition("form-data; name=\"metadata\"");
});

}
}

0 comments on commit 48beed0

Please sign in to comment.