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:
Oliver Gierke
2017-09-08 11:25:44 +02:00
parent f49b54418d
commit 8f269e28fe
4 changed files with 49 additions and 17 deletions

View File

@@ -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());

View File

@@ -0,0 +1,3 @@
[
{"op":"replace", "path":"/somethingInvalid", "value": "bar" }
]