-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BE] Refactor/#563 RestDocs 응답 오류(500) 해결 및 상태코드 검증 추가 #565
Changes from all commits
527f473
439c3d5
e0025bb
394185c
0680edb
e378b1e
5b948f8
d4cb5b2
a171e72
5336989
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
// == 관리자 기능 | ||
// | ||
// === 전체 회원 조회 | ||
// | ||
// operation::admin-controller-test/find-all-member-details[snippets='http-request,http-response'] | ||
// | ||
// === 회원 상세 조회 | ||
// | ||
// operation::admin-controller-test/find-member[snippets='http-request,http-response'] | ||
// | ||
// === 회원 차단(삭제) | ||
// | ||
// operation::admin-controller-test/delete-member[snippets='http-request,http-response'] | ||
// | ||
// === 토픽 삭제 | ||
// | ||
// operation::admin-controller-test/delete-topic[snippets='http-request,http-response'] | ||
// | ||
// === 토픽 이미지 삭제 | ||
// | ||
// operation::admin-controller-test/delete-topic-image[snippets='http-request,http-response'] | ||
// | ||
// === 핀 삭제 | ||
// | ||
// operation::admin-controller-test/delete-pin[snippets='http-request,http-response'] | ||
// | ||
// === 핀 이미지 삭제 | ||
// | ||
// operation::admin-controller-test/delete-pin-image[snippets='http-request,http-response'] | ||
== 관리자 기능 | ||
|
||
=== 전체 회원 조회 | ||
|
||
operation::admin-controller-test/find-all-member-details[snippets='http-request,http-response'] | ||
|
||
=== 회원 상세 조회 | ||
|
||
operation::admin-controller-test/find-member[snippets='http-request,http-response'] | ||
|
||
=== 회원 차단(삭제) | ||
|
||
operation::admin-controller-test/delete-member[snippets='http-request,http-response'] | ||
|
||
=== 토픽 삭제 | ||
|
||
operation::admin-controller-test/delete-topic[snippets='http-request,http-response'] | ||
|
||
=== 토픽 이미지 삭제 | ||
|
||
operation::admin-controller-test/delete-topic-image[snippets='http-request,http-response'] | ||
|
||
=== 핀 삭제 | ||
|
||
operation::admin-controller-test/delete-pin[snippets='http-request,http-response'] | ||
|
||
=== 핀 이미지 삭제 | ||
|
||
operation::admin-controller-test/delete-pin-image[snippets='http-request,http-response'] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,6 +65,7 @@ public ResponseEntity<Void> update( | |
.build(); | ||
} | ||
|
||
@Deprecated(since = "2023.10.10 (이미지 삭제 로직 불완전, 사용되지 않는 API)") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 최근들어 Deprecated 를 아주 야무지게 쓰시는군요 멋집니다 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 코드 나중에 보면 힘들거가타서여.. 근데 이것도 부채네요! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 그래도 이렇게 붙여주신 덕분에 추후에 볼 때 편할 것 같네요! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🪭 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
@LoginRequired | ||
@DeleteMapping("/{pinId}") | ||
public ResponseEntity<Void> delete(AuthMember member, @PathVariable Long pinId) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
import org.junit.jupiter.api.Test; | ||
import org.springframework.boot.test.mock.mockito.MockBean; | ||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; | ||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers; | ||
|
||
class AdminControllerTest extends RestDocsIntegration { | ||
|
||
|
@@ -74,7 +75,7 @@ class AdminControllerTest extends RestDocsIntegration { | |
private AdminAuthInterceptor adminAuthInterceptor; | ||
|
||
@BeforeEach | ||
void setAll() throws Exception { | ||
void setAll() { | ||
given(adminAuthInterceptor.preHandle(any(), any(), any())).willReturn(true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 굿굿 |
||
} | ||
|
||
|
@@ -88,10 +89,10 @@ void findAllMemberDetails() throws Exception { | |
|
||
given(adminQueryService.findAllMemberDetails()).willReturn(response); | ||
|
||
mockMvc.perform( | ||
MockMvcRequestBuilders.get("/admin/members") | ||
.header(AUTHORIZATION, testAuthHeaderProvider.createAuthHeaderById(1L)) | ||
).andDo(restDocs.document()); | ||
mockMvc.perform(MockMvcRequestBuilders.get("/admin/members") | ||
.header(AUTHORIZATION, "testKey")) | ||
.andExpect(MockMvcResultMatchers.status().isOk()) | ||
.andDo(restDocs.document()); | ||
} | ||
|
||
@DisplayName("멤버 상세 조회") | ||
|
@@ -109,64 +110,64 @@ void findMember() throws Exception { | |
|
||
given(adminQueryService.findMemberDetail(any())).willReturn(response); | ||
|
||
mockMvc.perform( | ||
MockMvcRequestBuilders.get("/admin/members/1") | ||
.header(AUTHORIZATION, testAuthHeaderProvider.createAuthHeaderById(1L)) | ||
).andDo(restDocs.document()); | ||
mockMvc.perform(MockMvcRequestBuilders.get("/admin/members/1") | ||
.header(AUTHORIZATION, "testKey")) | ||
.andExpect(MockMvcResultMatchers.status().isOk()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
.andDo(restDocs.document()); | ||
} | ||
|
||
@DisplayName("멤버 차단(블랙리스트)") | ||
@Test | ||
void deleteMember() throws Exception { | ||
doNothing().when(adminCommandService).blockMember(any()); | ||
|
||
mockMvc.perform( | ||
MockMvcRequestBuilders.delete("/admin/members/1") | ||
.header(AUTHORIZATION, testAuthHeaderProvider.createAuthHeaderById(1L)) | ||
).andDo(restDocs.document()); | ||
mockMvc.perform(MockMvcRequestBuilders.delete("/admin/members/1") | ||
.header(AUTHORIZATION, "testKey")) | ||
.andExpect(MockMvcResultMatchers.status().isNoContent()) | ||
.andDo(restDocs.document()); | ||
} | ||
|
||
@DisplayName("토픽 삭제") | ||
@Test | ||
void deleteTopic() throws Exception { | ||
doNothing().when(adminCommandService).deleteTopic(any()); | ||
|
||
mockMvc.perform( | ||
MockMvcRequestBuilders.delete("/admin/topics/1") | ||
.header(AUTHORIZATION, testAuthHeaderProvider.createAuthHeaderById(1L)) | ||
).andDo(restDocs.document()); | ||
mockMvc.perform(MockMvcRequestBuilders.delete("/admin/topics/1") | ||
.header(AUTHORIZATION, "testKey")) | ||
.andExpect(MockMvcResultMatchers.status().isNoContent()) | ||
.andDo(restDocs.document()); | ||
} | ||
|
||
@DisplayName("토픽 이미지 삭제") | ||
@Test | ||
void deleteTopicImage() throws Exception { | ||
doNothing().when(adminCommandService).deleteTopicImage(any()); | ||
|
||
mockMvc.perform( | ||
MockMvcRequestBuilders.delete("/admin/topics/1/images") | ||
.header(AUTHORIZATION, testAuthHeaderProvider.createAuthHeaderById(1L)) | ||
).andDo(restDocs.document()); | ||
mockMvc.perform(MockMvcRequestBuilders.delete("/admin/topics/1/images") | ||
.header(AUTHORIZATION, "testKey")) | ||
.andExpect(MockMvcResultMatchers.status().isNoContent()) | ||
.andDo(restDocs.document()); | ||
} | ||
|
||
@DisplayName("핀 삭제") | ||
@Test | ||
void deletePin() throws Exception { | ||
doNothing().when(adminCommandService).deletePin(any()); | ||
|
||
mockMvc.perform( | ||
MockMvcRequestBuilders.delete("/admin/pins/1") | ||
.header(AUTHORIZATION, testAuthHeaderProvider.createAuthHeaderById(1L)) | ||
).andDo(restDocs.document()); | ||
mockMvc.perform(MockMvcRequestBuilders.delete("/admin/pins/1") | ||
.header(AUTHORIZATION, "testKey")) | ||
.andExpect(MockMvcResultMatchers.status().isNoContent()) | ||
.andDo(restDocs.document()); | ||
} | ||
|
||
@DisplayName("토픽 이미지 삭제") | ||
@Test | ||
void deletePinImage() throws Exception { | ||
doNothing().when(adminCommandService).deletePinImage(any()); | ||
|
||
mockMvc.perform( | ||
MockMvcRequestBuilders.delete("/admin/pins/images/1") | ||
.header(AUTHORIZATION, testAuthHeaderProvider.createAuthHeaderById(1L)) | ||
).andDo(restDocs.document()); | ||
mockMvc.perform(MockMvcRequestBuilders.delete("/admin/pins/images/1") | ||
.header(AUTHORIZATION, "testKey")) | ||
.andExpect(MockMvcResultMatchers.status().isNoContent()) | ||
.andDo(restDocs.document()); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
관리자 기능 rest docs 를 재활성화 시키신 이유는 어짜피 Authorization 이 외부로 드러나 있지 않으니 안전하다고 판단하셔서인가요?
그냥 궁금해서 여쭤봅니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
네 맞습니다, 그리고 그 외에 지웠던 이유가 잘 기억이 안나서 편의상 다시 추가해보았는데 그럼에도 노출하지 않는게 좋다고 생각하시면 다시 되돌리겠습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
근데 그 때 잠깐 주석처리 했던 이유가, 굳이 admin api 명세를 모두가 볼 수 있도록 공개해야하나? 라는 가벼운 이유 였던 것 같아서 괜찮을 것 같긴합니다.
무엇보다 secret key 가 없다면, admin api 를 사용할 수 없기도 하구요.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
근데... 집에 벌써 가셨나요? 전광석화 또또이..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저는 깃허브 모바일 애용자입니다 ^_^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
킹쩔TV