Skip to content

Commit

Permalink
Role 관련 Header 변경 (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
kgh2120 authored May 6, 2023
1 parent e616348 commit b9211a6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
package com.liberty52.product.global.exception.external.forbidden;

<<<<<<< HEAD
=======
import com.liberty52.product.global.exception.external.forbidden.NotYourResourceException;

>>>>>>> dev
public class InvalidRoleException extends NotYourResourceException {
public InvalidRoleException(String role) {
super("Role", role);
}
<<<<<<< HEAD
}
=======
}
>>>>>>> dev
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class ReplyCreateController {
@PostMapping("/reviews/{reviewId}/replies")
@ResponseStatus(HttpStatus.CREATED)
public void createReply(@RequestHeader(HttpHeaders.AUTHORIZATION) String adminId,
@RequestHeader("X-ROLE") String role,
@RequestHeader("LB-Role") String role,
@Validated @RequestBody ReplyCreateRequestDto dto, @PathVariable String reviewId) {
replyCreateService.createReply(adminId,dto,reviewId, role);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,15 @@ class ReplyCreateControllerTest {
final String mockAdminRole = ADMIN;
final String mockUserRole = "USER";
final String mockReplyContent = "Hello world";
final String headerRole = "LB-Role";
@Test
void Craete_Reply_Success_Status_CRAETED () throws Exception{
//given
ReplyCreateRequestDto dto = ReplyCreateRequestDto.createForTest(mockReplyContent);
//when
mockMvc.perform(post(String.format(createReplyUrl,mockReviewId))
.header(HttpHeaders.AUTHORIZATION,mockAdminId)
.header("X-ROLE",mockAdminRole)
.header(headerRole,mockAdminRole)
.contentType(MediaType.APPLICATION_JSON)
.content(new ObjectMapper().writeValueAsString(dto)))
//then
Expand All @@ -88,7 +89,7 @@ void CREATE_REPLY_FAIL_STATUS_FORBIDDEN_InvalidRoleException () throws Exception
//when
mockMvc.perform(post(String.format(createReplyUrl,mockReviewId))
.header(HttpHeaders.AUTHORIZATION,mockAdminId)
.header("X-ROLE",mockUserRole)
.header(headerRole,mockUserRole)
.contentType(MediaType.APPLICATION_JSON)
.content(new ObjectMapper().writeValueAsString(dto)))
//then
Expand Down Expand Up @@ -120,7 +121,7 @@ void CREATE_REPLY_FAIL_STATUS_NOT_FOUND_ResourceNotFoundException () throws Exce
//when
mockMvc.perform(post(String.format(createReplyUrl,mockReviewId))
.header(HttpHeaders.AUTHORIZATION,mockAdminId)
.header("X-ROLE",mockAdminRole)
.header(headerRole,mockAdminRole)
.contentType(MediaType.APPLICATION_JSON)
.content(new ObjectMapper().writeValueAsString(dto)))
//then
Expand Down

0 comments on commit b9211a6

Please sign in to comment.