-
Notifications
You must be signed in to change notification settings - Fork 0
[feat] 작곡가 삭제 API 추가 #97
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ | |
| import static org.springframework.restdocs.cookies.CookieDocumentation.requestCookies; | ||
| import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; | ||
| import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName; | ||
| import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; | ||
| import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; | ||
| import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
|
||
|
|
@@ -76,6 +77,35 @@ public class ComposerControllerTest extends ControllerTestSupport { | |
| )); | ||
| } | ||
|
|
||
| @Test | ||
| void 작곡가를_삭제한다() throws Exception { | ||
|
Comment on lines
+80
to
+81
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. |
||
| // given | ||
| Long composerId = 1L; | ||
| Cookie cookie = new Cookie(COOKIE_NAME, "access_token"); | ||
|
|
||
| // when | ||
| ResultActions result = mockMvc.perform(delete("/composers/{composerId}", composerId) | ||
| .cookie(cookie) | ||
| ); | ||
|
|
||
| // then | ||
| result.andExpect(status().isNoContent()) | ||
| .andDo(restDocsHandler.document( | ||
| resource(ResourceSnippetParameters.builder() | ||
| .tag("Composer API") | ||
| .summary("작곡가 삭제") | ||
| .description("관리자가 작곡가를 삭제합니다.") | ||
| .pathParameters( | ||
| parameterWithName("composerId").description("삭제할 작곡가 ID") | ||
| ) | ||
| .build() | ||
| ), | ||
| requestCookies( | ||
| cookieWithName(COOKIE_NAME).description("유저의 토큰") | ||
| ) | ||
| )); | ||
| } | ||
|
|
||
| @Test | ||
| void 작곡가_좋아요를_토글한다() throws Exception { | ||
| // given | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The authorization check relies on a hardcoded user ID (
5L) to identify the administrator. This is a critical security vulnerability as user IDs are often predictable, potentially leading to privilege escalation if a regular user is assigned this ID. It also introduces maintainability issues, as this 'magic number' is difficult to understand and manage if admin policies change. It is strongly recommended to implement a proper Role-Based Access Control (RBAC) system. This involves adding arolefield to theUserentity and checking for anADMINrole instead of a hardcoded ID. This will enhance both security and maintainability.