diff --git a/backend/src/test/java/org/raddatz/familienarchiv/document/comment/CommentControllerTest.java b/backend/src/test/java/org/raddatz/familienarchiv/document/comment/CommentControllerTest.java index 473b1a7a..7b047617 100644 --- a/backend/src/test/java/org/raddatz/familienarchiv/document/comment/CommentControllerTest.java +++ b/backend/src/test/java/org/raddatz/familienarchiv/document/comment/CommentControllerTest.java @@ -94,6 +94,15 @@ class CommentControllerTest { .andExpect(status().isForbidden()); } + @Test + @WithMockUser(authorities = "READ_ALL") + void postBlockComment_returns403_whenUserHasOnlyReadAllPermission() throws Exception { + UUID blockId = UUID.randomUUID(); + mockMvc.perform(post("/api/documents/" + DOC_ID + "/transcription-blocks/" + blockId + "/comments").with(csrf()) + .contentType(MediaType.APPLICATION_JSON).content(COMMENT_JSON)) + .andExpect(status().isForbidden()); + } + @Test @WithMockUser(authorities = "ANNOTATE_ALL") void postBlockComment_returns201_whenHasAnnotatePermission() throws Exception { @@ -142,6 +151,16 @@ class CommentControllerTest { .andExpect(status().isUnauthorized()); } + @Test + @WithMockUser(authorities = "READ_ALL") + void replyToBlockComment_returns403_whenUserHasOnlyReadAllPermission() throws Exception { + UUID blockId = UUID.randomUUID(); + mockMvc.perform(post("/api/documents/" + DOC_ID + "/transcription-blocks/" + blockId + + "/comments/" + COMMENT_ID + "/replies").with(csrf()) + .contentType(MediaType.APPLICATION_JSON).content(COMMENT_JSON)) + .andExpect(status().isForbidden()); + } + @Test @WithMockUser(authorities = "ANNOTATE_ALL") void replyToBlockComment_returns201_whenHasPermission() throws Exception { @@ -181,6 +200,14 @@ class CommentControllerTest { .andExpect(status().isUnauthorized()); } + @Test + @WithMockUser(authorities = "READ_ALL") + void editComment_returns403_whenUserHasOnlyReadAllPermission() throws Exception { + mockMvc.perform(patch("/api/documents/" + DOC_ID + "/comments/" + COMMENT_ID).with(csrf()) + .contentType(MediaType.APPLICATION_JSON).content(COMMENT_JSON)) + .andExpect(status().isForbidden()); + } + @Test @WithMockUser(authorities = "ANNOTATE_ALL") void editComment_returns200_whenHasPermission() throws Exception {