Skip to content

Commit

Permalink
fix: CARITAS-243
Browse files Browse the repository at this point in the history
* remove PATH_UPLOAD_FILE_TO_FEEDBACK_ROOM
  • Loading branch information
Leandro13Silva13 committed Aug 9, 2024
1 parent 458abc0 commit dd26e6c
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 156 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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 {

Expand Down Expand Up @@ -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 {

Expand All @@ -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 {

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}

0 comments on commit dd26e6c

Please sign in to comment.