From 86c50e93e2bf3eb3b7b657c0f3cbdd5ceeed6249 Mon Sep 17 00:00:00 2001 From: Siarhei Hrabko <45555481+grabsefx@users.noreply.github.com> Date: Mon, 20 Jan 2025 12:19:59 +0300 Subject: [PATCH] EPMRPP-97478 delete deprecated endpoints (#2147) --- .../ws/controller/FileStorageController.java | 45 +------------------ .../controller/FileStorageControllerTest.java | 26 +---------- 2 files changed, 2 insertions(+), 69 deletions(-) diff --git a/src/main/java/com/epam/ta/reportportal/ws/controller/FileStorageController.java b/src/main/java/com/epam/ta/reportportal/ws/controller/FileStorageController.java index 8887197554..4752c2839a 100644 --- a/src/main/java/com/epam/ta/reportportal/ws/controller/FileStorageController.java +++ b/src/main/java/com/epam/ta/reportportal/ws/controller/FileStorageController.java @@ -19,13 +19,12 @@ import static com.epam.ta.reportportal.auth.permissions.Permissions.ALLOWED_TO_VIEW_PROJECT; import static com.epam.ta.reportportal.auth.permissions.Permissions.IS_ADMIN; -import com.epam.ta.reportportal.commons.EntityUtils; +import com.epam.reportportal.rules.exception.ReportPortalException; import com.epam.ta.reportportal.commons.ReportPortalUser; import com.epam.ta.reportportal.core.file.DeleteFilesHandler; import com.epam.ta.reportportal.core.file.GetFileHandler; import com.epam.ta.reportportal.core.user.EditUserHandler; import com.epam.ta.reportportal.entity.attachment.BinaryData; -import com.epam.reportportal.rules.exception.ReportPortalException; import com.epam.ta.reportportal.util.ProjectExtractor; import com.epam.ta.reportportal.ws.reporting.OperationCompletionRS; import com.google.common.net.HttpHeaders; @@ -41,7 +40,6 @@ import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; @@ -83,47 +81,6 @@ public void getFile(@PathVariable String projectKey, @PathVariable("dataId") Lon projectExtractor.extractMembershipDetails(user, projectKey))); } - @Transactional(readOnly = true) - @GetMapping(value = "/photo") - @Operation(summary = "Get photo of current user") - @Deprecated(forRemoval = true) - public void getMyPhoto(@AuthenticationPrincipal ReportPortalUser user, - HttpServletResponse response, - @RequestParam(value = "loadThumbnail", required = false) boolean loadThumbnail) { - toResponse(response, getFileHandler.getUserPhoto(user, loadThumbnail)); - } - - @Transactional(readOnly = true) - @GetMapping(value = "/{projectKey}/userphoto") - @Operation(summary = "Get user's photo") - @PreAuthorize(ALLOWED_TO_VIEW_PROJECT) - @Deprecated(forRemoval = true) - public void getUserPhoto(@PathVariable String projectKey, - @RequestParam(value = "login") String username, - @RequestParam(value = "loadThumbnail", required = false) boolean loadThumbnail, - HttpServletResponse response, - @AuthenticationPrincipal ReportPortalUser user) { - BinaryData userPhoto = getFileHandler.getUserPhoto(EntityUtils.normalizeId(username), user, - projectKey, loadThumbnail); - toResponse(response, userPhoto); - } - - @Transactional - @PostMapping(value = "/photo", consumes = {MediaType.MULTIPART_FORM_DATA_VALUE}) - @Operation(summary = "Upload user's photo") - @Deprecated(forRemoval = true) - public OperationCompletionRS uploadPhoto(@RequestParam("file") MultipartFile file, - @AuthenticationPrincipal ReportPortalUser user) { - return editUserHandler.uploadPhoto(EntityUtils.normalizeId(user.getUsername()), file); - } - - @Transactional - @DeleteMapping(value = "/photo") - @Operation(summary = "Delete user's photo") - @Deprecated(forRemoval = true) - public OperationCompletionRS deletePhoto(@AuthenticationPrincipal ReportPortalUser user) { - return editUserHandler.deletePhoto(EntityUtils.normalizeId(user.getUsername())); - } @Transactional @PreAuthorize(IS_ADMIN) diff --git a/src/test/java/com/epam/ta/reportportal/ws/controller/FileStorageControllerTest.java b/src/test/java/com/epam/ta/reportportal/ws/controller/FileStorageControllerTest.java index e7a6250833..2bebb0b4ee 100644 --- a/src/test/java/com/epam/ta/reportportal/ws/controller/FileStorageControllerTest.java +++ b/src/test/java/com/epam/ta/reportportal/ws/controller/FileStorageControllerTest.java @@ -65,22 +65,10 @@ void userPhoto() throws Exception { mockMvc.perform(get("/users/2/avatar").with(token(oAuthHelper.getDefaultToken()))) .andExpect(status().isOk()); - mockMvc.perform(get("/v1/data/default_personal/userphoto?login=default").with( - token(oAuthHelper.getDefaultToken()))) - .andExpect(status().isOk()); - mockMvc.perform(delete("/users/2/avatar").with(token(oAuthHelper.getDefaultToken()))) .andExpect(status().isNoContent()); } - @Test - @Sql("/db/user/user-viewer.sql") - void testUserPhotoAccessDeniedForCustomer() throws Exception { - mockMvc.perform(get("/v1/data/default_personal/userphoto?login=default").with( - token(oAuthHelper.getCustomerToken()))) - .andExpect(status().isForbidden()); - } - @Test void uploadLargeUserPhoto() throws Exception { final MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders.multipart( @@ -157,23 +145,11 @@ void getFile() throws Exception { .andExpect(status().isOk()); } - @Test - void getUserPhotoNegative() throws Exception { - mockMvc.perform(get("/v1/data/photo").with(token(oAuthHelper.getDefaultToken()))) - .andExpect(status().isOk()); - } - - @Test - void getUserPhotoByLoginNegative() throws Exception { - mockMvc.perform(get("/v1/data/superadmin_personal/userphoto?login=superadmin").with( - token(oAuthHelper.getSuperadminToken()))) - .andExpect(status().isOk()); - } @Test void getNotExistUserPhoto() throws Exception { mockMvc.perform( - get("/v1/data/userphoto?login=not_exist") + get("/users/999/avatar") .with(token(oAuthHelper.getSuperadminToken()))) .andExpect(status().isNotFound()); }