Skip to content

Commit

Permalink
feat: HTTP Method를 POST에서 GET으로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
3Juhwan committed Aug 8, 2024
1 parent b9ea942 commit 68bbae6
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public ResponseEntity<Void> loginEvent(
.build();
}

@PostMapping("/api/events/{eventId}/auth")
@GetMapping("/api/events/{eventId}/auth")
public ResponseEntity<Void> authenticate(@PathVariable("eventId") String token) {
return ResponseEntity.ok().build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,27 +71,27 @@ void saveEvent() throws Exception {
given(authService.getTokenName()).willReturn("eventToken");

mockMvc.perform(post("/api/events")
.contentType(MediaType.APPLICATION_JSON)
.content(requestBody))
.contentType(MediaType.APPLICATION_JSON)
.content(requestBody))
.andDo(print())
.andExpect(status().isOk())
.andExpect(cookie().value("eventToken", "jwtToken"))
.andExpect(jsonPath("$.eventId").value("쿠키 토큰"))
.andDo(
document("createEvent",
preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()),
requestFields(
fieldWithPath("eventName").type(JsonFieldType.STRING).description("행사 이름"),
fieldWithPath("password").type(JsonFieldType.STRING).description("행사 비밀 번호")
),
responseFields(
fieldWithPath("eventId").type(JsonFieldType.STRING)
.description("행사 ID")
),
responseCookies(
cookieWithName("eventToken").description("행사 관리자용 토큰")
)
preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()),
requestFields(
fieldWithPath("eventName").type(JsonFieldType.STRING).description("행사 이름"),
fieldWithPath("password").type(JsonFieldType.STRING).description("행사 비밀 번호")
),
responseFields(
fieldWithPath("eventId").type(JsonFieldType.STRING)
.description("행사 ID")
),
responseCookies(
cookieWithName("eventToken").description("행사 관리자용 토큰")
)
)
);
}
Expand All @@ -109,14 +109,14 @@ void findEventTest() throws Exception {
.andExpect(jsonPath("$.eventName").value("행동대장 회식"))
.andDo(
document("getEvent",
preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()),
pathParameters(
parameterWithName("eventId").description("행사 ID")
),
responseFields(
fieldWithPath("eventName").type(JsonFieldType.STRING).description("행사 이름")
)
preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()),
pathParameters(
parameterWithName("eventId").description("행사 ID")
),
responseFields(
fieldWithPath("eventName").type(JsonFieldType.STRING).description("행사 이름")
)
)
);
}
Expand All @@ -135,15 +135,15 @@ void findAllMembersTest() throws Exception {
.andExpect(jsonPath("$.memberNames[1]").value("쿠키"))
.andDo(
document("findAllEventMember",
preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()),
pathParameters(
parameterWithName("eventId").description("행사 ID")
),
responseFields(
fieldWithPath("memberNames").type(JsonFieldType.ARRAY)
.description("행사 참여자 목록")
)
preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()),
pathParameters(
parameterWithName("eventId").description("행사 ID")
),
responseFields(
fieldWithPath("memberNames").type(JsonFieldType.ARRAY)
.description("행사 참여자 목록")
)
)
);
}
Expand All @@ -156,25 +156,25 @@ void updateMember() throws Exception {
String requestBody = objectMapper.writeValueAsString(memberUpdateRequest);

mockMvc.perform(put("/api/events/{eventId}/members/{memberName}", token, "변경 전 이름")
.cookie(EVENT_COOKIE)
.contentType(MediaType.APPLICATION_JSON)
.content(requestBody))
.cookie(EVENT_COOKIE)
.contentType(MediaType.APPLICATION_JSON)
.content(requestBody))
.andDo(print())
.andExpect(status().isOk())
.andDo(
document("updateEventMemberName",
preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()),
pathParameters(
parameterWithName("eventId").description("행사 ID"),
parameterWithName("memberName").description("참여자 이름")
),
requestCookies(
cookieWithName("eventToken").description("행사 관리자 토큰")
),
requestFields(
fieldWithPath("name").type(JsonFieldType.STRING).description("수정할 참여자 이름")
)
preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()),
pathParameters(
parameterWithName("eventId").description("행사 ID"),
parameterWithName("memberName").description("참여자 이름")
),
requestCookies(
cookieWithName("eventToken").description("행사 관리자 토큰")
),
requestFields(
fieldWithPath("name").type(JsonFieldType.STRING).description("수정할 참여자 이름")
)
)
);
}
Expand All @@ -189,25 +189,25 @@ void loginEvent() throws Exception {
given(authService.getTokenName()).willReturn("eventToken");

mockMvc.perform(post("/api/events/{eventId}/login", token)
.contentType(MediaType.APPLICATION_JSON)
.content(requestBody))
.contentType(MediaType.APPLICATION_JSON)
.content(requestBody))
.andDo(print())
.andExpect(cookie().value("eventToken", "jwtToken"))
.andExpect(status().isOk())
.andDo(
document("eventLogin",
preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()),
pathParameters(
parameterWithName("eventId").description("행사 ID")
),
requestFields(
fieldWithPath("password").type(JsonFieldType.STRING)
.description("행사 비밀 번호")
),
responseCookies(
cookieWithName("eventToken").description("행사 관리자용 토큰")
)
preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()),
pathParameters(
parameterWithName("eventId").description("행사 ID")
),
requestFields(
fieldWithPath("password").type(JsonFieldType.STRING)
.description("행사 비밀 번호")
),
responseCookies(
cookieWithName("eventToken").description("행사 관리자용 토큰")
)
)
);
}
Expand All @@ -225,7 +225,7 @@ void findActions() throws Exception {
given(eventService.findActions(token)).willReturn(actionAppResponses);

mockMvc.perform(get("/api/events/{eventId}/actions", token)
.accept(MediaType.APPLICATION_JSON))
.accept(MediaType.APPLICATION_JSON))
.andDo(print())
.andExpect(status().isOk())
.andExpect(jsonPath("$.steps[0].type").value(equalTo("IN")))
Expand Down Expand Up @@ -255,25 +255,25 @@ void findActions() throws Exception {

.andDo(
document("findActions",
preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()),
pathParameters(
parameterWithName("eventId").description("행사 ID")
),
responseFields(
fieldWithPath("steps[].type").type(JsonFieldType.STRING)
.description("액션 유형 [BILL, IN, OUT]"),
fieldWithPath("steps[].members").type(JsonFieldType.ARRAY)
.description("해당 step에 참여한 참여자 목록"),
fieldWithPath("steps[].actions[].actionId").type(JsonFieldType.NUMBER)
.description("액션 ID"),
fieldWithPath("steps[].actions[].name").type(JsonFieldType.STRING)
.description("참여자 액션일 경우 참여자 이름, 지출 액션일 경우 지출 내역 이름"),
fieldWithPath("steps[].actions[].price").type(JsonFieldType.NUMBER).optional()
.description("참여자 액션일 경우 null, 지출 액션일 경우 지출 금액"),
fieldWithPath("steps[].actions[].sequence").type(JsonFieldType.NUMBER)
.description("액션 순서")
)
preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()),
pathParameters(
parameterWithName("eventId").description("행사 ID")
),
responseFields(
fieldWithPath("steps[].type").type(JsonFieldType.STRING)
.description("액션 유형 [BILL, IN, OUT]"),
fieldWithPath("steps[].members").type(JsonFieldType.ARRAY)
.description("해당 step에 참여한 참여자 목록"),
fieldWithPath("steps[].actions[].actionId").type(JsonFieldType.NUMBER)
.description("액션 ID"),
fieldWithPath("steps[].actions[].name").type(JsonFieldType.STRING)
.description("참여자 액션일 경우 참여자 이름, 지출 액션일 경우 지출 내역 이름"),
fieldWithPath("steps[].actions[].price").type(JsonFieldType.NUMBER).optional()
.description("참여자 액션일 경우 null, 지출 액션일 경우 지출 금액"),
fieldWithPath("steps[].actions[].sequence").type(JsonFieldType.NUMBER)
.description("액션 순서")
)
)
);
}
Expand All @@ -282,7 +282,7 @@ void findActions() throws Exception {
@Test
void authenticateTest() throws Exception {
String token = "TOKEN";
mockMvc.perform(post("/api/events/{eventId}/auth", token)
mockMvc.perform(get("/api/events/{eventId}/auth", token)
.cookie(EVENT_COOKIE))
.andDo(print())
.andExpect(status().isOk())
Expand Down

0 comments on commit 68bbae6

Please sign in to comment.