/** * Perform a PATCH request to a <code>path</code>. Normally the path doesn't have to be fully-qualified e.g. you don't need to * specify the path as <tt>http://localhost:8080/path</tt>. In this case it's enough to use <tt>/path</tt>. * * @param path The path to send the request to. * @param pathParams The path parameters. E.g. if path is "/book/{hotelId}/{roomNumber}" you can do <code>head("/book/{hotelName}/{roomNumber}", "Hotels R Us", 22);</code>. * @return The response of the request. */ public static Response patch(String path, Object... pathParams) { return given().patch(path, pathParams); }
/** * Perform a PATCH request to a <code>uri</code>. * * @param uri The uri to send the request to. * @return The response of the request. */ public static Response patch(URI uri) { return given().patch(uri); }
/** * Perform a PATCH request to a <code>url</code>. * * @param url The url to send the request to. * @return The response of the request. */ public static Response patch(URL url) { return given().patch(url); }
/** * Perform a PATCH request to a <code>path</code>. Normally the path doesn't have to be fully-qualified e.g. you don't need to * specify the path as <tt>http://localhost:8080/path</tt>. In this case it's enough to use <tt>/path</tt>. * * @param path The path to send the request to. * @param pathParams The path parameters. * @return The response of the request. */ public static Response patch(String path, Map<String, ?> pathParams) { return given().patch(path, pathParams); }
/** * Perform a PATCH request to the statically configured path (by default <code>http://localhost:8080</code>). * * @return The response of the request. */ public static Response patch() { return given().patch(); }
@Test(priority = 39) public void testPatchExtNoCommit() { String req = jsonParser.getJson("/ResourceIT/testPatchExtNoCommit.req.json"); given() .contentType(JSONAPI_CONTENT_TYPE_WITH_JSON_PATCH_EXTENSION) .accept(JSONAPI_CONTENT_TYPE_WITH_JSON_PATCH_EXTENSION) .body(req) .patch("/") .then() .statusCode(HttpStatus.SC_FORBIDDEN) .body(equalTo("{\"errors\":[\"ForbiddenAccessException\"]}")); }
@Test(priority = 2) public void testAuditWithDuplicateLineageEntry() { String request = jsonParser.getJson("/AuditIT/updateAuditEntityLineageDup.req.json"); given() .contentType(JSONAPI_CONTENT_TYPE) .accept(JSONAPI_CONTENT_TYPE) .body(request) .patch("/auditEntity/2/otherEntity/1") .then() .statusCode(HttpStatus.SC_NO_CONTENT); Assert.assertTrue(logger.logMessages.contains("Updated value (for id: 1): update id 1 through id 2")); }
@Test(priority = 3) public void testPatchAttrList() throws Exception { String request = jsonParser.getJson("/ResourceIT/testPatchAttrList.json"); given() .contentType(JSONAPI_CONTENT_TYPE) .accept(JSONAPI_CONTENT_TYPE) .body(request) .patch("/parent/3") .then() .statusCode(HttpStatus.SC_BAD_REQUEST); }
@Test(priority = 25) public void checkJsonApiPatchWithError() { String request = jsonParser.getJson("/ResourceIT/checkJsonApiPatchWithError.req.json"); String expected = jsonParser.getJson("/ResourceIT/checkJsonApiPatchWithError.json"); given() .contentType(JSONAPI_CONTENT_TYPE_WITH_JSON_PATCH_EXTENSION) .accept(JSONAPI_CONTENT_TYPE_WITH_JSON_PATCH_EXTENSION) .body(request) .patch("/parent") .then() .statusCode(HttpStatus.SC_BAD_REQUEST) .body(equalTo(expected)); }
@Test(priority = 27) public void patchExtAddUpdate() { String request = jsonParser.getJson("/ResourceIT/patchExtAddUpdate.req.json"); String expected = jsonParser.getJson("/ResourceIT/patchExtAddUpdate.json"); given() .contentType(JSONAPI_CONTENT_TYPE_WITH_JSON_PATCH_EXTENSION) .accept(JSONAPI_CONTENT_TYPE_WITH_JSON_PATCH_EXTENSION) .body(request) .patch("/") .then() .statusCode(HttpStatus.SC_OK) .body(equalTo(expected)); }
@Test(priority = 13) public void createDependentPatchExt() { String request = jsonParser.getJson("/ResourceIT/createDependentPatchExt.req.json"); String expected = jsonParser.getJson("/ResourceIT/createDependentPatchExt.json"); given() .contentType(JSONAPI_CONTENT_TYPE_WITH_JSON_PATCH_EXTENSION) .accept(JSONAPI_CONTENT_TYPE_WITH_JSON_PATCH_EXTENSION) .body(request) .patch("/parent") .then() .statusCode(HttpStatus.SC_OK) .body(equalTo(expected)); }
@Test public void testPatchDeferredOnCreate() { String request = jsonParser.getJson("/ResourceIT/testPatchDeferredOnCreate.req.json"); String expected = jsonParser.getJson("/ResourceIT/testPatchDeferredOnCreate.json"); given() .contentType(JSONAPI_CONTENT_TYPE_WITH_JSON_PATCH_EXTENSION) .accept(JSONAPI_CONTENT_TYPE_WITH_JSON_PATCH_EXTENSION) .body(request) .patch("/") .then() .statusCode(HttpStatus.SC_FORBIDDEN) .body(equalTo(expected)); }
@Test public void testPrivilegeEscalation() throws Exception { String request = jsonParser.getJson("/ResourceIT/testUserRoleModification.req.json"); given() .contentType(JSONAPI_CONTENT_TYPE) .accept(JSONAPI_CONTENT_TYPE) .body(request) .patch("/user/1") .then() .statusCode(HttpStatus.SC_FORBIDDEN); }
@Test(priority = 36) public void testNestedPatch() { String req = jsonParser.getJson("/ResourceIT/nestedPatchCreate.req.json"); String expected = jsonParser.getJson("/ResourceIT/nestedPatchCreate.resp.json"); given() .contentType(JSONAPI_CONTENT_TYPE_WITH_JSON_PATCH_EXTENSION) .accept(JSONAPI_CONTENT_TYPE_WITH_JSON_PATCH_EXTENSION) .body(req) .patch("/parent") .then() .statusCode(HttpStatus.SC_OK) .body(equalTo(expected)); }
@Test(priority = 29) public void patchExtBadDelete() { String request = jsonParser.getJson("/ResourceIT/patchExtBadDelete.req.json"); String expected = jsonParser.getJson("/ResourceIT/patchExtBadDelete.json"); given() .contentType(JSONAPI_CONTENT_TYPE_WITH_JSON_PATCH_EXTENSION) .accept(JSONAPI_CONTENT_TYPE_WITH_JSON_PATCH_EXTENSION) .body(request) .patch("/") .then() .statusCode(HttpStatus.SC_BAD_REQUEST) .body(equalTo(expected)); }
@Test(priority = 14) public void createChildRelateExisting() { String request = jsonParser.getJson("/ResourceIT/createChildRelateExisting.req.json"); String expected = jsonParser.getJson("/ResourceIT/createChildRelateExisting.json"); given() .contentType(JSONAPI_CONTENT_TYPE_WITH_JSON_PATCH_EXTENSION) .accept(JSONAPI_CONTENT_TYPE_WITH_JSON_PATCH_EXTENSION) .body(request) .patch("/") .then() .statusCode(HttpStatus.SC_OK) .body(equalTo(expected)); }
@Test(priority = 26) public void patchExtBadId() { String request = jsonParser.getJson("/ResourceIT/patchExtBadId.req.json"); String expected = jsonParser.getJson("/ResourceIT/patchExtBadId.json"); given() .contentType(JSONAPI_CONTENT_TYPE_WITH_JSON_PATCH_EXTENSION) .accept(JSONAPI_CONTENT_TYPE_WITH_JSON_PATCH_EXTENSION) .body(request) .patch("/") .then() .statusCode(HttpStatus.SC_BAD_REQUEST) .body(equalTo(expected)); }
@Test(priority = 6) public void testPatchRelNoUpdateSingle() { String request = jsonParser.getJson("/ResourceIT/testPatchRelNoUpdateSingle.json"); given() .contentType(JSONAPI_CONTENT_TYPE) .accept(JSONAPI_CONTENT_TYPE) .body(request) .patch("/parent/4") .then() .statusCode(HttpStatus.SC_NO_CONTENT) .header(HttpHeaders.CONTENT_LENGTH, (String) null); }
@Test(priority = 10) public void testPatchRelNoUpdateDirect() throws Exception { String request = jsonParser.getJson("/ResourceIT/testPatchRelNoUpdateDirect.json"); given() .contentType(JSONAPI_CONTENT_TYPE) .accept(JSONAPI_CONTENT_TYPE) .body(request) .patch("/parent/4/relationships/children") .then() .statusCode(HttpStatus.SC_NO_CONTENT) .header(HttpHeaders.CONTENT_LENGTH, (String) null); }
@Test(priority = 2) public void testPatchAttrNoUpdateSingle() { String request = jsonParser.getJson("/ResourceIT/testPatchAttrNoUpdateSingle.json"); given() .contentType(JSONAPI_CONTENT_TYPE) .accept(JSONAPI_CONTENT_TYPE) .body(request) .patch("/parent/2") .then() .statusCode(HttpStatus.SC_NO_CONTENT) .body(isEmptyOrNullString()); }