-
Notifications
You must be signed in to change notification settings - Fork 0
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
[refactor] : login된 유저 조회 api가 email을 함께 반환하도록 수정 #406
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b7802fe
fix: JWT decrypt 예외시 AuthException을 던지도록하고, 전역 Advice를 등록 (#403)
devxb 1ffe225
[refactor] : login된 유저 조회 api가 email을 함께 반환하도록 수정 (#401)
devxb 38990cb
feat: User 삭제 API 개발 (#405)
devxb 3988ace
refactor: TokenInfo를 record로 변경하고 token-value 부분을 받도록 수정한다 (#407)
devxb 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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
73 changes: 73 additions & 0 deletions
73
...rc/test/java/me/nalab/luffy/api/acceptance/test/user/delete/UserDeleteAcceptanceTest.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package me.nalab.luffy.api.acceptance.test.user.delete; | ||
|
||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
||
import java.time.Instant; | ||
import java.util.Set; | ||
import me.nalab.auth.application.common.dto.Payload; | ||
import me.nalab.auth.application.common.utils.JwtUtils; | ||
import me.nalab.auth.mock.api.MockUserRegisterEvent; | ||
import me.nalab.luffy.api.acceptance.test.TargetInitializer; | ||
import me.nalab.luffy.api.acceptance.test.UserInitializer; | ||
import me.nalab.luffy.api.acceptance.test.user.UserAcceptanceTestSupporter; | ||
import me.nalab.user.domain.user.Provider; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.autoconfigure.domain.EntityScan; | ||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.context.ApplicationEventPublisher; | ||
import org.springframework.context.annotation.ComponentScan; | ||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories; | ||
import org.springframework.test.context.TestPropertySource; | ||
|
||
@SpringBootTest | ||
@AutoConfigureMockMvc | ||
@TestPropertySource("classpath:h2.properties") | ||
@ComponentScan("me.nalab") | ||
@EnableJpaRepositories(basePackages = {"me.nalab"}) | ||
@EntityScan(basePackages = {"me.nalab"}) | ||
class UserDeleteAcceptanceTest extends UserAcceptanceTestSupporter { | ||
|
||
@Autowired | ||
private ApplicationEventPublisher applicationEventPublisher; | ||
|
||
@Autowired | ||
private TargetInitializer targetInitializer; | ||
|
||
@Autowired | ||
private JwtUtils jwtUtils; | ||
|
||
@Autowired | ||
private UserInitializer userInitializer; | ||
|
||
@Test | ||
@DisplayName("DELETE /v1/users API는 token에 해당하는 유저가 삭제되면 200 OK를 반환한다.") | ||
void DELETE_USER_SUCCESS() throws Exception { | ||
// given | ||
String nickname = "delete_user_success"; | ||
String email = "delete_user_success"; | ||
|
||
var token = "bearer " + createUserAndSetToken(nickname, email); | ||
|
||
// when | ||
var result = deleteUser(token); | ||
|
||
// then | ||
result.andExpect(status().isOk()); | ||
} | ||
|
||
private String createUserAndSetToken(String nickname, String email) { | ||
Long userId = userInitializer.saveUserWithOAuth(Provider.DEFAULT, nickname, email, Instant.now()); | ||
Long targetId = targetInitializer.saveTargetAndGetId(nickname, Instant.now()); | ||
|
||
var token = jwtUtils.createAccessToken(Set.of(new Payload(Payload.Key.USER_ID, String.valueOf(userId)), | ||
new Payload(Payload.Key.TARGET_ID, String.valueOf(targetId)))); | ||
|
||
applicationEventPublisher.publishEvent( | ||
MockUserRegisterEvent.builder().expectedToken("bearer " + token).expectedId(targetId).build()); | ||
|
||
return token; | ||
} | ||
} |
Oops, something went wrong.
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.
토큰 만드는 책임을 넘기거나 Authentication Type을 public static 으로 풀면 좋을 것 같음!