Skip to content
Snippets Groups Projects
Commit 4feca6cf authored by Piotr Gawron's avatar Piotr Gawron
Browse files

project with version above 20 characters cannot be created

parent 96ce43b7
No related branches found
No related tags found
1 merge request!934Resolve "restrict Version to 20 characters"
Pipeline #13930 passed
......@@ -386,6 +386,9 @@ public class ProjectRestImpl extends BaseRestImpl {
params.sbgnFormat(getFirstValue(data.get("sbgn")));
params.semanticZoomContainsMultipleLayouts(getFirstValue(data.get("semantic-zoom-contains-multiple-layouts")));
params.version(getFirstValue(data.get("version")));
if (params.getVersion() != null && params.getVersion().length() > 20) {
throw new QueryException("version is too long (>20 characters)");
}
params.annotations(getFirstValue(data.get("annotate")));
params.setUser(user);
MapCanvasType mapCanvasType;
......
......@@ -130,6 +130,35 @@ public class ProjectControllerIntegrationTestWithoutTransaction extends Controll
}
}
@Test
public void addProjectWithTooLongVersion() throws Exception {
User admin = userService.getUserByLogin(BUILT_IN_ADMIN_LOGIN);
UploadedFileEntry fileEntry = createFileInSeparateThread(
new String(Files.readAllBytes(Paths.get("./src/test/resources/generic.xml")), "UTF-8"),
admin);
try {
String invalidVersion = "12345678901234567890123456";
String body = EntityUtils.toString(new UrlEncodedFormEntity(Arrays.asList(
new BasicNameValuePair("file-id", String.valueOf(fileEntry.getId())),
new BasicNameValuePair("mapCanvasType", "OPEN_LAYERS"),
new BasicNameValuePair("version", invalidVersion),
new BasicNameValuePair("parser",
"lcsb.mapviewer.converter.model.celldesigner.CellDesignerXmlParser"))));
RequestBuilder request = post("/projects/" + TEST_PROJECT)
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.content(body)
.session(createSession(BUILT_IN_ADMIN_LOGIN, BUILT_IN_ADMIN_PASSWORD));
mockMvc.perform(request).andExpect(status().isBadRequest());
} finally {
removeFileInSeparateThread(fileEntry);
removeProjectInSeparateThread(TEST_PROJECT);
}
}
@Test
public void modifyProjectWithTooLongName() throws Exception {
createProjectInSeparateThread(TEST_PROJECT);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment