Skip to content

Commit

Permalink
test: Check request body has no "multipart/mixed" part
Browse files Browse the repository at this point in the history
  • Loading branch information
Ludovic Heitz committed Jul 27, 2023
1 parent d0770bf commit 214a36f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions karate-core/src/test/java/com/intuit/karate/TestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public static void matchContains(Object actual, Object expected) {
Match.Result mr = Match.evaluate(actual).contains(expected);
assertTrue(mr.pass, mr.message);
}

public static void notContains(Object actual, Object expected) {
Match.Result mr = Match.evaluate(actual).isNotContaining(expected);
assertTrue(mr.pass, mr.message);
}

public static ScenarioEngine engine() {
return new ScenarioEngine(new Config(), runtime(), new HashMap(), new Logger());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,23 @@ void testMultiPartFile() {
matchVar("response", "{ foo: [{ name: 'foo', value: '#notnull', contentType: 'text/plain', charset: 'UTF-8', filename: 'foo.txt', transferEncoding: '7bit' }] }");
}

@Test
void testMultiPartFiles() {
background().scenario(
"pathMatches('/hello')",
"def response = requestParts");
run(
URL_STEP,
"def file1 = { name: 'file', filename: 'file1.txt', value: 'Hello 1' }",
"def file2 = { name: 'file', filename: 'file2.txt', value: 'Hello 2' }",
"multipart files ([file1, file2])",
"path 'hello'",
"method post"
);
runtime.engine.assign(AssignType.STRING, "prevReqBody", "karate.prevRequest.body", false);
notContains(get("prevReqBody"), "multipart/mixed");
}

@Test
void testMultiPartFileNullCharset() {
background().scenario(
Expand Down

0 comments on commit 214a36f

Please sign in to comment.