Skip to content

Commit

Permalink
refactor: merge confilt 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
parksey committed Nov 15, 2023
1 parent 4c4bf89 commit 038fb2a
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@
import com.moabam.api.dto.auth.TokenSaveValue;
import com.moabam.global.config.EmbeddedRedisConfig;
import com.moabam.global.config.RedisConfig;
<<<<<<< HEAD
import com.moabam.global.error.exception.UnauthorizedException;
import com.moabam.global.error.model.ErrorMessage;
=======
>>>>>>> b7ca2493ffc73b73c54b3b68b1378b7261f21dcf
import com.moabam.support.fixture.TokenSaveValueFixture;

@SpringBootTest(classes = {RedisConfig.class, EmbeddedRedisConfig.class, HashTemplateRepository.class})
Expand Down Expand Up @@ -64,7 +61,6 @@ void delete_and_get_null() {
hashTemplateRepository.delete(key);

// When + Then
<<<<<<< HEAD
assertThatThrownBy(() -> hashTemplateRepository.get(key))
.isInstanceOf(UnauthorizedException.class)
.hasMessage(ErrorMessage.AUTHENTICATE_FAIL.getMessage());
Expand All @@ -77,8 +73,5 @@ void valid_token_failby_token_is_null() {
assertThatThrownBy(() -> hashTemplateRepository.get("0"))
.isInstanceOf(UnauthorizedException.class)
.hasMessage(ErrorMessage.AUTHENTICATE_FAIL.getMessage());
=======
assertThat(hashTemplateRepository.get(key)).isNull();
>>>>>>> b7ca2493ffc73b73c54b3b68b1378b7261f21dcf
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.moabam.global.filter;

import static org.assertj.core.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;

import java.io.IOException;
Expand Down Expand Up @@ -140,44 +139,6 @@ void filter_have_any_refresh_token_error() throws ServletException, IOException
eq(null), any(UnauthorizedException.class));
}

@DisplayName("에러 발생 시 모든 토큰 만료")
@Test
void error_with_expire_token() throws ServletException, IOException {
// given
JwtProviderService jwtProviderService = JwtProviderFixture.jwtProviderService();
PublicClaim publicClaim = PublicClaimFixture.publicClaim();

MockHttpServletResponse httpServletResponse = new MockHttpServletResponse();
MockHttpServletRequest httpServletRequest = new MockHttpServletRequest();
MockFilterChain mockFilterChain = new MockFilterChain();

// when
String token = jwtProviderService.provideAccessToken(publicClaim);
httpServletRequest.setCookies(
new Cookie("token_type", "Bearer"),
new Cookie("access_token", token));

when(jwtAuthenticationService.parseClaim(token)).thenReturn(publicClaim);
when(jwtAuthenticationService.isTokenExpire(token)).thenReturn(true);

// when
authorizationFilter.doFilter(httpServletRequest, httpServletResponse, mockFilterChain);
Cookie cookie = httpServletResponse.getCookie("access_token");

// then
assertAll(
() -> assertThat(cookie).isNotNull(),
() -> assertThat(cookie.getMaxAge()).isZero(),
() -> assertThat(cookie.getValue()).isEqualTo(token)
);

verify(handlerExceptionResolver, times(1))
.resolveException(
eq(httpServletRequest), eq(httpServletResponse),
eq(null), any(UnauthorizedException.class));

}

@DisplayName("새로운 도큰 발급 성공")
@Test
void issue_new_token_success() throws ServletException, IOException {
Expand Down

0 comments on commit 038fb2a

Please sign in to comment.