diff --git a/backend/baton/src/main/java/touch/baton/domain/oauth/token/ExpireDate.java b/backend/baton/src/main/java/touch/baton/domain/oauth/token/ExpireDate.java index 35e2aac74..b20bf6af0 100644 --- a/backend/baton/src/main/java/touch/baton/domain/oauth/token/ExpireDate.java +++ b/backend/baton/src/main/java/touch/baton/domain/oauth/token/ExpireDate.java @@ -30,8 +30,8 @@ private void validateNotNull(final LocalDateTime value) { } } - public void plusMinutes(final int minutes) { - this.value = value.plusMinutes(minutes); + public void refreshExpireTokenDate(final int minutes) { + this.value = LocalDateTime.now().plusMinutes(minutes); } public boolean isExpired() { diff --git a/backend/baton/src/main/java/touch/baton/domain/oauth/token/RefreshToken.java b/backend/baton/src/main/java/touch/baton/domain/oauth/token/RefreshToken.java index c4d37e018..0f42590f3 100644 --- a/backend/baton/src/main/java/touch/baton/domain/oauth/token/RefreshToken.java +++ b/backend/baton/src/main/java/touch/baton/domain/oauth/token/RefreshToken.java @@ -64,7 +64,7 @@ private void validateNotNull(final Member member, final Token token, final Expir public void updateToken(final Token token, final int expiredMinutes) { this.token = token; - expireDate.plusMinutes(expiredMinutes); + expireDate.refreshExpireTokenDate(expiredMinutes); } public boolean isNotOwner(final Member member) { diff --git a/backend/baton/src/test/java/touch/baton/domain/oauth/token/RefreshTokenTest.java b/backend/baton/src/test/java/touch/baton/domain/oauth/token/RefreshTokenTest.java index f1cac4ade..0d3e7c5ba 100644 --- a/backend/baton/src/test/java/touch/baton/domain/oauth/token/RefreshTokenTest.java +++ b/backend/baton/src/test/java/touch/baton/domain/oauth/token/RefreshTokenTest.java @@ -15,6 +15,7 @@ import java.time.LocalDateTime; import static java.time.LocalDateTime.now; +import static java.time.temporal.ChronoUnit.MINUTES; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -99,8 +100,8 @@ void updateToken() { // then assertAll( () -> assertThat(refreshToken.getToken()).isEqualTo(updateToken), - () -> assertThat(refreshToken.getExpireDate()).isEqualTo(new ExpireDate(currentTime.plusMinutes(30))) - ); + () -> assertThat(refreshToken.getExpireDate().getValue().truncatedTo(MINUTES)) + .isEqualTo((currentTime.plusMinutes(30)).truncatedTo(MINUTES))); } @DisplayName("토큰의 주인을 확인할 수 있다.")