-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: RefreshToken을 Redis Entity로 변경
- Loading branch information
Showing
6 changed files
with
21 additions
and
63 deletions.
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
19 changes: 5 additions & 14 deletions
19
backend/src/main/java/hanglog/login/domain/RefreshToken.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 |
---|---|---|
@@ -1,26 +1,17 @@ | ||
package hanglog.login.domain; | ||
|
||
import static lombok.AccessLevel.PROTECTED; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Id; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import org.springframework.data.annotation.Id; | ||
import org.springframework.data.redis.core.RedisHash; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor(access = PROTECTED) | ||
@AllArgsConstructor | ||
@RedisHash(value = "refreshToken", timeToLive = 604800) | ||
public class RefreshToken { | ||
|
||
@Id | ||
private String token; | ||
|
||
@Column(nullable = false) | ||
private Long memberId; | ||
|
||
public RefreshToken(final String token, final Long memberId) { | ||
this.token = token; | ||
this.memberId = memberId; | ||
} | ||
} |
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
58 changes: 16 additions & 42 deletions
58
backend/src/test/java/hanglog/integration/service/LoginServiceIntegrationTest.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 |
---|---|---|
@@ -1,66 +1,40 @@ | ||
package hanglog.integration.service; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
|
||
import hanglog.community.domain.repository.PublishedTripRepository; | ||
import hanglog.login.domain.OauthProviders; | ||
import hanglog.login.domain.repository.RefreshTokenRepository; | ||
import hanglog.login.infrastructure.BearerAuthorizationExtractor; | ||
import hanglog.login.infrastructure.JwtProvider; | ||
import hanglog.login.service.LoginService; | ||
import hanglog.member.domain.Member; | ||
import hanglog.member.domain.repository.MemberRepository; | ||
import hanglog.trip.domain.repository.SharedTripRepository; | ||
import hanglog.trip.domain.repository.TripRepository; | ||
import hanglog.trip.infrastructure.CustomTripRepositoryImpl; | ||
import jakarta.persistence.EntityManager; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.context.ApplicationEventPublisher; | ||
import org.springframework.context.annotation.Import; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.context.jdbc.Sql; | ||
|
||
@Import({ | ||
LoginService.class, | ||
OauthProviders.class, | ||
JwtProvider.class, | ||
BearerAuthorizationExtractor.class, | ||
CustomTripRepositoryImpl.class | ||
}) | ||
class LoginServiceIntegrationTest extends ServiceIntegrationTest { | ||
@SpringBootTest | ||
@Sql(value = {"classpath:data/truncate.sql"}) | ||
class LoginServiceIntegrationTest { | ||
|
||
@Autowired | ||
private OauthProviders oauthProviders; | ||
@Autowired | ||
private RefreshTokenRepository refreshTokenRepository; | ||
@Autowired | ||
private TripRepository tripRepository; | ||
@Autowired | ||
private JwtProvider jwtProvider; | ||
@Autowired | ||
private BearerAuthorizationExtractor bearerExtractor; | ||
@Autowired | ||
private LoginService loginService; | ||
@Autowired | ||
private PublishedTripRepository publishedTripRepository; | ||
@Autowired | ||
private MemberRepository memberRepository; | ||
@Autowired | ||
private SharedTripRepository sharedTripRepository; | ||
@Autowired | ||
private ApplicationEventPublisher publisher; | ||
@Autowired | ||
private EntityManager entityManager; | ||
|
||
@DisplayName("멤버를 삭제한다.") | ||
@Test | ||
void deleteAccount() { | ||
// when & then | ||
// given | ||
final Member member = memberRepository.save(new Member( | ||
"socialLoginId", | ||
"name", | ||
"https://hanglog.com/img/imageName.png" | ||
)); | ||
assertThat(memberRepository.findById(member.getId())).isPresent(); | ||
assertDoesNotThrow(() -> loginService.deleteAccount(member.getId())); | ||
entityManager.flush(); | ||
entityManager.clear(); | ||
|
||
// when | ||
loginService.deleteAccount(member.getId()); | ||
|
||
// then | ||
assertThat(memberRepository.findById(member.getId())).isEmpty(); | ||
} | ||
} |
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