Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Devrim Gunyel
core
Commits
566cf0f3
Commit
566cf0f3
authored
Nov 13, 2019
by
Piotr Gawron
Browse files
invalid file id returns 400 not 500
parent
76ea198f
Changes
2
Hide whitespace changes
Inline
Side-by-side
rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectRestImpl.java
View file @
566cf0f3
...
...
@@ -349,7 +349,7 @@ public class ProjectRestImpl extends BaseRestImpl {
if
(
fileId
==
null
)
{
throw
new
QueryException
(
"file-id is obligatory"
);
}
UploadedFileEntry
file
=
uploadedFileEntryDao
.
getById
(
Integer
.
valueOf
(
fileId
));
UploadedFileEntry
file
=
uploadedFileEntryDao
.
getById
(
super
.
parseInteger
(
fileId
,
"
fileId
"
));
if
(
file
==
null
)
{
throw
new
QueryException
(
"Invalid file id: "
+
fileId
);
}
...
...
web/src/test/java/lcsb/mapviewer/web/ProjectControllerIntegrationTest.java
View file @
566cf0f3
...
...
@@ -4,6 +4,11 @@ import static org.junit.Assert.*;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.*;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
status
;
import
java.util.Arrays
;
import
org.apache.http.client.entity.UrlEncodedFormEntity
;
import
org.apache.http.message.BasicNameValuePair
;
import
org.apache.http.util.EntityUtils
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.junit.Before
;
...
...
@@ -25,7 +30,7 @@ import lcsb.mapviewer.model.security.PrivilegeType;
import
lcsb.mapviewer.model.user.User
;
import
lcsb.mapviewer.persist.dao.ProjectDao
;
import
lcsb.mapviewer.services.interfaces.IUserService
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@Transactional
@Rollback
...
...
@@ -321,4 +326,21 @@ public class ProjectControllerIntegrationTest extends ControllerIntegrationTest
.
andExpect
(
status
().
isNotFound
());
}
@Test
(
timeout
=
10000
)
public
void
addProjectWithInvalidFileId
()
throws
Exception
{
MockHttpSession
session
=
createSession
(
BUILT_IN_TEST_ADMIN_LOGIN
,
BUILT_IN_TEST_ADMIN_PASSWORD
);
String
body
=
EntityUtils
.
toString
(
new
UrlEncodedFormEntity
(
Arrays
.
asList
(
new
BasicNameValuePair
(
"file-id"
,
String
.
valueOf
(
""
)),
new
BasicNameValuePair
(
"mapCanvasType"
,
"OPEN_LAYERS"
),
new
BasicNameValuePair
(
"parser"
,
"lcsb.mapviewer.converter.model.celldesigner.CellDesignerXmlParser"
))));
RequestBuilder
request
=
post
(
"/projects/projectId"
)
.
contentType
(
MediaType
.
APPLICATION_FORM_URLENCODED
)
.
content
(
body
)
.
session
(
session
);
mockMvc
.
perform
(
request
).
andExpect
(
status
().
is4xxClientError
());
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment