diff --git a/src/test/java/de/caritas/cob/uploadservice/api/controller/UploadControllerAuthorizationTestIT.java b/src/test/java/de/caritas/cob/uploadservice/api/controller/UploadControllerAuthorizationTestIT.java index fdbc05d..5a5f711 100644 --- a/src/test/java/de/caritas/cob/uploadservice/api/controller/UploadControllerAuthorizationTestIT.java +++ b/src/test/java/de/caritas/cob/uploadservice/api/controller/UploadControllerAuthorizationTestIT.java @@ -1,7 +1,6 @@ package de.caritas.cob.uploadservice.api.controller; import static de.caritas.cob.uploadservice.helper.PathConstants.PATH_UPDATE_KEY; -import static de.caritas.cob.uploadservice.helper.PathConstants.PATH_UPLOAD_FILE_TO_FEEDBACK_ROOM; import static de.caritas.cob.uploadservice.helper.PathConstants.PATH_UPLOAD_FILE_TO_ROOM; import static de.caritas.cob.uploadservice.helper.TestConstants.CSRF_COOKIE; import static de.caritas.cob.uploadservice.helper.TestConstants.CSRF_HEADER; @@ -155,54 +154,6 @@ public void uploadFileToRoom_Should_ReturnForbiddenAndCallNoMethods_WhenNoCsrfTo verifyNoMoreInteractions(uploadFacade); } - @Test - public void uploadFileToFeedbackRoom_Should_Return401AndCallNoMethods_WhenNoKeycloakAuthorization() - throws Exception { - - mvc.perform( - post(PATH_UPLOAD_FILE_TO_FEEDBACK_ROOM + "/" + RC_ROOM_ID) - .cookie(csrfCookie) - .header(CSRF_HEADER, CSRF_VALUE) - .contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isUnauthorized()); - - verifyNoMoreInteractions(rocketChatService); - verifyNoMoreInteractions(uploadFacade); - } - - @Test - @WithMockUser - public void uploadFileToFeedbackRoom_Should_Return403AndCallNoMethods_WhenNoUserOrConsultantAuthority() - throws Exception { - - mvc.perform( - post(PATH_UPLOAD_FILE_TO_FEEDBACK_ROOM + "/" + RC_ROOM_ID) - .cookie(csrfCookie) - .header(CSRF_HEADER, CSRF_VALUE) - .contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isForbidden()); - - verifyNoMoreInteractions(rocketChatService); - verifyNoMoreInteractions(uploadFacade); - } - - @Test - @WithMockUser(authorities = {AuthorityValue.CONSULTANT_DEFAULT, AuthorityValue.USER_DEFAULT}) - public void uploadFileToFeedbackRoom_Should_ReturnForbiddenAndCallNoMethods_WhenNoCsrfTokens() - throws Exception { - - mvc.perform( - post(PATH_UPLOAD_FILE_TO_FEEDBACK_ROOM + "/" + RC_ROOM_ID) - .contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isForbidden()); - - verifyNoMoreInteractions(rocketChatService); - verifyNoMoreInteractions(uploadFacade); - } - @Test @WithMockUser(authorities = {AuthorityValue.ANONYMOUS_DEFAULT}) public void uploadFileToRoom_Should_ReturnCreated_When_AnonymousAuthority() diff --git a/src/test/java/de/caritas/cob/uploadservice/api/controller/UploadControllerTestIT.java b/src/test/java/de/caritas/cob/uploadservice/api/controller/UploadControllerTestIT.java index 822c7f1..e81a97f 100644 --- a/src/test/java/de/caritas/cob/uploadservice/api/controller/UploadControllerTestIT.java +++ b/src/test/java/de/caritas/cob/uploadservice/api/controller/UploadControllerTestIT.java @@ -1,7 +1,6 @@ package de.caritas.cob.uploadservice.api.controller; import static de.caritas.cob.uploadservice.helper.PathConstants.PATH_UPDATE_KEY; -import static de.caritas.cob.uploadservice.helper.PathConstants.PATH_UPLOAD_FILE_TO_FEEDBACK_ROOM; import static de.caritas.cob.uploadservice.helper.PathConstants.PATH_UPLOAD_FILE_TO_ROOM; import static de.caritas.cob.uploadservice.helper.TestConstants.FORM_PARAM_DESCRIPTION; import static de.caritas.cob.uploadservice.helper.TestConstants.FORM_PARAM_DESCRIPTION_VALUE; @@ -93,25 +92,6 @@ public void uploadFileToRoom_Should_ReturnNotFound_WhenRoomIdIsMissing() throws .andExpect(status().isNotFound()); } - @Test - public void uploadFileToFeedbackRoom_Should_ReturnNotFound_WhenRoomIdIsMissing() - throws Exception { - - MockPart fileToUpload = new MockPart(FORM_PARAM_FILE, "fileToUpload", "content".getBytes()); - - mvc.perform( - multipart(PATH_UPLOAD_FILE_TO_FEEDBACK_ROOM) - .part(fileToUpload) - .param(FORM_PARAM_SEND_NOTIFICATION, FORM_PARAM_SEND_NOTIFICATION_TRUE) - .param(FORM_PARAM_DESCRIPTION, FORM_PARAM_DESCRIPTION_VALUE) - .param(FORM_PARAM_MESSAGE, FORM_PARAM_MESSAGE_VALUE) - .param(FORM_PARAM_TMID, FORM_PARAM_TMID_VALUE) - .contentType(MediaType.MULTIPART_FORM_DATA) - .header(RC_TOKEN_HEADER_PARAMETER_NAME, RC_TOKEN) - .header(RC_USER_ID_HEADER_PARAMETER_NAME, RC_USER_ID)) - .andExpect(status().isNotFound()); - } - @Test public void uploadFileToRoom_Should_ReturnBadRequest_WhenFileIsMissing() throws Exception { @@ -145,40 +125,6 @@ public void uploadFileToRoom_Should_ReturnBadRequest_WhenSendNotificationIsMissi .andExpect(status().isBadRequest()); } - @Test - public void uploadFileToFeedbackRoom_Should_ReturnBadRequest_WhenFileIsMissing() - throws Exception { - - mvc.perform( - multipart(PATH_UPLOAD_FILE_TO_FEEDBACK_ROOM + "/" + RC_ROOM_ID) - .param(FORM_PARAM_SEND_NOTIFICATION, FORM_PARAM_SEND_NOTIFICATION_TRUE) - .param(FORM_PARAM_DESCRIPTION, FORM_PARAM_DESCRIPTION_VALUE) - .param(FORM_PARAM_MESSAGE, FORM_PARAM_MESSAGE_VALUE) - .param(FORM_PARAM_TMID, FORM_PARAM_TMID_VALUE) - .contentType(MediaType.MULTIPART_FORM_DATA) - .header(RC_TOKEN_HEADER_PARAMETER_NAME, RC_TOKEN) - .header(RC_USER_ID_HEADER_PARAMETER_NAME, RC_USER_ID)) - .andExpect(status().isBadRequest()); - } - - @Test - public void uploadFileToFeedbackRoom_Should_ReturnBadRequest_WhenSendNotificationIsMissing() - throws Exception { - - MockPart fileToUpload = new MockPart(FORM_PARAM_FILE, "fileToUpload", "content".getBytes()); - - mvc.perform( - multipart(PATH_UPLOAD_FILE_TO_FEEDBACK_ROOM + "/" + RC_ROOM_ID) - .part(fileToUpload) - .param(FORM_PARAM_DESCRIPTION, FORM_PARAM_DESCRIPTION_VALUE) - .param(FORM_PARAM_MESSAGE, FORM_PARAM_MESSAGE_VALUE) - .param(FORM_PARAM_TMID, FORM_PARAM_TMID_VALUE) - .contentType(MediaType.MULTIPART_FORM_DATA) - .header(RC_TOKEN_HEADER_PARAMETER_NAME, RC_TOKEN) - .header(RC_USER_ID_HEADER_PARAMETER_NAME, RC_USER_ID)) - .andExpect(status().isBadRequest()); - } - @Test public void uploadFileToRoom_Should_ReturnOk_WhenValidRequest() throws Exception { @@ -197,24 +143,6 @@ public void uploadFileToRoom_Should_ReturnOk_WhenValidRequest() throws Exception .andExpect(status().isCreated()); } - @Test - public void uploadFileToFeedbackRoom_Should_ReturnOk_WhenValidRequest() throws Exception { - - MockPart fileToUpload = new MockPart(FORM_PARAM_FILE, "fileToUpload", "content".getBytes()); - - mvc.perform( - multipart(PATH_UPLOAD_FILE_TO_FEEDBACK_ROOM + "/" + RC_ROOM_ID) - .part(fileToUpload) - .param(FORM_PARAM_SEND_NOTIFICATION, FORM_PARAM_SEND_NOTIFICATION_TRUE) - .param(FORM_PARAM_DESCRIPTION, FORM_PARAM_DESCRIPTION_VALUE) - .param(FORM_PARAM_MESSAGE, FORM_PARAM_MESSAGE_VALUE) - .param(FORM_PARAM_TMID, FORM_PARAM_TMID_VALUE) - .contentType(MediaType.MULTIPART_FORM_DATA) - .header(RC_TOKEN_HEADER_PARAMETER_NAME, RC_TOKEN) - .header(RC_USER_ID_HEADER_PARAMETER_NAME, RC_USER_ID)) - .andExpect(status().isCreated()); - } - @Test public void updateKey_Should_ReturnOk_WhenProvidedWithNewKey() throws Exception { @@ -256,22 +184,6 @@ public void uploadFileToRoom_Should_ReturnOk_When_notRequiredParamsAreMissing() .andExpect(status().isCreated()); } - @Test - public void uploadFileToFeedbackRoom_Should_ReturnOk_When_notRequiredParamsAreMissing() - throws Exception { - - MockPart fileToUpload = new MockPart(FORM_PARAM_FILE, "fileToUpload", "content".getBytes()); - - mvc.perform( - multipart(PATH_UPLOAD_FILE_TO_FEEDBACK_ROOM + "/" + RC_ROOM_ID) - .part(fileToUpload) - .param(FORM_PARAM_SEND_NOTIFICATION, FORM_PARAM_SEND_NOTIFICATION_TRUE) - .contentType(MediaType.MULTIPART_FORM_DATA) - .header(RC_TOKEN_HEADER_PARAMETER_NAME, RC_TOKEN) - .header(RC_USER_ID_HEADER_PARAMETER_NAME, RC_USER_ID)) - .andExpect(status().isCreated()); - } - @Test public void uploadFileToRoom_Should_ReturnForbiddenWithCustomHeader_When_quotaLimitIsReached() throws Exception { @@ -315,22 +227,4 @@ public void uploadFileToRoom_should_return_unsupported_media_type_on_InvalidFile .header(RC_USER_ID_HEADER_PARAMETER_NAME, RC_USER_ID)) .andExpect(status().isUnsupportedMediaType()); } - - @Test - public void uploadFileToFeedbackRoom_should_return_unsupported_media_type_on_InvalidFileTypeException() - throws Exception { - doThrow(InvalidFileTypeException.class).when(uploadFacade) - .uploadFileToFeedbackRoom(any(RocketChatCredentials.class), - any(RocketChatUploadParameter.class), anyBoolean(), nullable(String.class), nullable(String.class)); - MockPart fileToUpload = new MockPart(FORM_PARAM_FILE, "fileToUpload", "content".getBytes()); - - mvc.perform( - multipart(PATH_UPLOAD_FILE_TO_FEEDBACK_ROOM + "/" + RC_ROOM_ID) - .part(fileToUpload) - .param(FORM_PARAM_SEND_NOTIFICATION, FORM_PARAM_SEND_NOTIFICATION_TRUE) - .contentType(MediaType.MULTIPART_FORM_DATA) - .header(RC_TOKEN_HEADER_PARAMETER_NAME, RC_TOKEN) - .header(RC_USER_ID_HEADER_PARAMETER_NAME, RC_USER_ID)) - .andExpect(status().isUnsupportedMediaType()); - } } diff --git a/src/test/java/de/caritas/cob/uploadservice/helper/PathConstants.java b/src/test/java/de/caritas/cob/uploadservice/helper/PathConstants.java index 3f597ea..9a3f001 100644 --- a/src/test/java/de/caritas/cob/uploadservice/helper/PathConstants.java +++ b/src/test/java/de/caritas/cob/uploadservice/helper/PathConstants.java @@ -4,5 +4,4 @@ public class PathConstants { public static final String PATH_UPDATE_KEY = "/uploads/messages/key"; public static final String PATH_UPLOAD_FILE_TO_ROOM = "/uploads/new"; - public static final String PATH_UPLOAD_FILE_TO_FEEDBACK_ROOM = "/uploads/feedback/new"; }