Commit f5f8b54c authored by Piotr Gawron's avatar Piotr Gawron
Browse files

project version cannot be changed to string above 20 characters

parent 2ae2c51d
......@@ -261,14 +261,13 @@ public class ProjectRestImpl extends BaseRestImpl {
stringValue = (String) value;
}
if (fieldName.equalsIgnoreCase("version")) {
if (value != null && ((String) value).length() > 20) {
throw new QueryException("version is too long (>20 characters)");
}
project.setVersion((String) value);
} else if (fieldName.equalsIgnoreCase("id")) {
try {
int id = Integer.parseInt(stringValue);
if (id != project.getId()) {
throw new QueryException("Invalid id: " + stringValue);
}
} catch (NumberFormatException e) {
int id = parseInteger(stringValue, "id");
if (id != project.getId()) {
throw new QueryException("Invalid id: " + stringValue);
}
} else if (fieldName.equalsIgnoreCase("projectId")) {
......@@ -277,7 +276,7 @@ public class ProjectRestImpl extends BaseRestImpl {
}
} else if (fieldName.equalsIgnoreCase("name")) {
if (value != null && ((String) value).length() > 255) {
throw new QueryException("name is too long");
throw new QueryException("name is too long (>255 characters)");
}
project.setName((String) value);
} else if (fieldName.equalsIgnoreCase("notifyEmail")) {
......
......@@ -206,6 +206,22 @@ public class ProjectControllerIntegrationTest extends ControllerIntegrationTest
}
@Test
public void testUpdateProjectWithTooLongVersion() throws Exception {
MockHttpSession session = createSession(ADMIN_LOGIN, ADMIN_PASSWORD);
createProject(TEST_PROJECT);
String content = "{\"project\":{\"version\":\"12345678901234567890123456\"}}";
RequestBuilder request = patch("/projects/" + TEST_PROJECT + "/")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.content(content)
.session(session);
mockMvc.perform(request)
.andExpect(status().isBadRequest());
}
@Test
public void testUpdateProjectWithUndefinedProjectId() throws Exception {
MockHttpSession session = createSession(ADMIN_LOGIN, ADMIN_PASSWORD);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment