DATAREST-1127 - Patch operations now always verify paths before operation application.
Previously the SpEL expresssion created from JSON Patch path expressions were executed without double checking whether these paths actually exist on the target object in the first place. This is now in place.
This commit is contained in:
@@ -162,6 +162,11 @@ public class JsonPatchTests {
|
||||
patch.apply(todo, Todo.class);
|
||||
}
|
||||
|
||||
@Test(expected = PatchException.class) // DATAREST-1127
|
||||
public void rejectsInvalidPaths() throws Exception {
|
||||
readJsonPatch("patch-invalid-path.json").apply(new Todo(), Todo.class);
|
||||
}
|
||||
|
||||
private Patch readJsonPatch(String jsonPatchFile) throws IOException, JsonParseException, JsonMappingException {
|
||||
|
||||
ClassPathResource resource = new ClassPathResource(jsonPatchFile, getClass());
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
[
|
||||
{"op":"replace", "path":"/somethingInvalid", "value": "bar" }
|
||||
]
|
||||
Reference in New Issue
Block a user