All multipart/form-data ITs should use multipart(), not post() or fileUpload()

This commit is contained in:
Tim Donohue
2022-02-18 16:41:30 -06:00
parent 0311aeb45c
commit 51591047d2
9 changed files with 91 additions and 108 deletions

View File

@@ -9,7 +9,7 @@ package org.dspace.curate;
import static com.jayway.jsonpath.JsonPath.read;
import static org.hamcrest.Matchers.is;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.multipart;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@@ -87,9 +87,8 @@ public class CurationScriptIT extends AbstractControllerIntegrationTest {
// Request with -t <invalidTaskOption>
getClient(token)
.perform(post(CURATE_SCRIPT_ENDPOINT).contentType("multipart/form-data")
.param("properties",
new Gson().toJson(list)))
.perform(multipart(CURATE_SCRIPT_ENDPOINT)
.param("properties", new Gson().toJson(list)))
// Illegal Argument Exception
.andExpect(status().isBadRequest());
}
@@ -109,9 +108,8 @@ public class CurationScriptIT extends AbstractControllerIntegrationTest {
// Request with missing required -i <handle>
getClient(token)
.perform(post(CURATE_SCRIPT_ENDPOINT).contentType("multipart/form-data")
.param("properties",
new Gson().toJson(list)))
.perform(multipart(CURATE_SCRIPT_ENDPOINT)
.param("properties", new Gson().toJson(list)))
// Illegal Argument Exception
.andExpect(status().isBadRequest());
}
@@ -132,9 +130,8 @@ public class CurationScriptIT extends AbstractControllerIntegrationTest {
// Request with missing required -i <handle>
getClient(token)
.perform(post(CURATE_SCRIPT_ENDPOINT).contentType("multipart/form-data")
.param("properties",
new Gson().toJson(list)))
.perform(multipart(CURATE_SCRIPT_ENDPOINT)
.param("properties", new Gson().toJson(list)))
// Illegal Argument Exception
.andExpect(status().isBadRequest());
}
@@ -173,9 +170,8 @@ public class CurationScriptIT extends AbstractControllerIntegrationTest {
// Request without -t <task> or -T <taskFile> (and no -q <queue>)
getClient(token)
.perform(post(CURATE_SCRIPT_ENDPOINT).contentType("multipart/form-data")
.param("properties",
new Gson().toJson(list)))
.perform(multipart(CURATE_SCRIPT_ENDPOINT)
.param("properties", new Gson().toJson(list)))
// Illegal Argument Exception
.andExpect(status().isBadRequest());
}
@@ -196,9 +192,8 @@ public class CurationScriptIT extends AbstractControllerIntegrationTest {
// Request with invalid -s <scope>; must be object, curation or open
getClient(token)
.perform(post(CURATE_SCRIPT_ENDPOINT).contentType("multipart/form-data")
.param("properties",
new Gson().toJson(list)))
.perform(multipart(CURATE_SCRIPT_ENDPOINT)
.param("properties", new Gson().toJson(list)))
// Illegal Argument Exception
.andExpect(status().isBadRequest());
}
@@ -219,9 +214,8 @@ public class CurationScriptIT extends AbstractControllerIntegrationTest {
// Request with invalid -s <scope>; must be object, curation or open
getClient(token)
.perform(post(CURATE_SCRIPT_ENDPOINT).contentType("multipart/form-data")
.param("properties",
new Gson().toJson(list)))
.perform(multipart(CURATE_SCRIPT_ENDPOINT)
.param("properties", new Gson().toJson(list)))
// Illegal Argument Exception
.andExpect(status().isBadRequest());
}
@@ -262,9 +256,8 @@ public class CurationScriptIT extends AbstractControllerIntegrationTest {
try {
getClient(token)
.perform(post(CURATE_SCRIPT_ENDPOINT).contentType("multipart/form-data")
.param("properties",
new Gson().toJson(list)))
.perform(multipart(CURATE_SCRIPT_ENDPOINT)
.param("properties", new Gson().toJson(list)))
.andExpect(status().isAccepted())
.andExpect(jsonPath("$", is(
ProcessMatcher.matchProcess("curate",
@@ -314,9 +307,8 @@ public class CurationScriptIT extends AbstractControllerIntegrationTest {
try {
getClient(token)
.perform(post(CURATE_SCRIPT_ENDPOINT).contentType("multipart/form-data")
.param("properties",
new Gson().toJson(list)))
.perform(multipart(CURATE_SCRIPT_ENDPOINT)
.param("properties", new Gson().toJson(list)))
.andExpect(status().isAccepted())
.andExpect(jsonPath("$", is(
ProcessMatcher.matchProcess("curate",
@@ -366,9 +358,8 @@ public class CurationScriptIT extends AbstractControllerIntegrationTest {
try {
getClient(token)
.perform(post(CURATE_SCRIPT_ENDPOINT).contentType("multipart/form-data")
.param("properties",
new Gson().toJson(list)))
.perform(multipart(CURATE_SCRIPT_ENDPOINT)
.param("properties", new Gson().toJson(list)))
.andExpect(jsonPath("$", is(
ProcessMatcher.matchProcess("curate",
String.valueOf(admin.getID()), parameters,