Skip to content

Commit

Permalink
fix: 테스트 오류 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
joohyun1996 committed Apr 12, 2024
1 parent 0f87d53 commit ba1e5d4
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void TestRefreshSuccess_accessExpired(){
String refresh = "refresh";
String uuid = "uuid";

Mockito.when(request.getHeader("Authority")).thenReturn(access);
Mockito.when(request.getHeader("Authorization")).thenReturn(access);
Mockito.when(tokenService.findRefreshByUUID(Mockito.any())).thenAnswer(new Answer<String>() {
private int count = 0;

Expand All @@ -63,7 +63,7 @@ public String answer(InvocationOnMock invocation) {

Assertions.assertAll(
() -> Assertions.assertEquals(HttpStatus.OK, result.getStatusCode()),
() -> Assertions.assertEquals("Bearer newAccess", response.getHeader("Authority"))
() -> Assertions.assertEquals("Bearer newAccess", response.getHeader("Authorization"))
);
}

Expand All @@ -76,7 +76,7 @@ public void TestRefreshSuccess_accessNotExpired(){
String newAccess = "newAccess";
String refresh = "refresh";

Mockito.when(request.getHeader("Authority")).thenReturn(access);
Mockito.when(request.getHeader("Authorization")).thenReturn(access);
Mockito.when(tokenService.findRefreshByUUID(Mockito.any())).thenReturn(refresh);

Mockito.when(jwtUtils.getUserName(Mockito.any())).thenReturn("1");
Expand All @@ -93,7 +93,7 @@ public void TestRefreshSuccess_accessNotExpired(){

Assertions.assertAll(
() -> Assertions.assertEquals(HttpStatus.OK, result.getStatusCode()),
() -> Assertions.assertEquals("Bearer newAccess", response.getHeader("Authority"))
() -> Assertions.assertEquals("Bearer newAccess", response.getHeader("Authorization"))
);
}

Expand All @@ -102,7 +102,7 @@ public void TestRefreshFailed_AuthorityNotFound(){
HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
MockHttpServletResponse response = new MockHttpServletResponse();

String header = request.getHeader("Authority");
String header = request.getHeader("Authorization");
Mockito.when(header == null).thenReturn(null);
Exception exception = Assertions.assertThrows(TokenNotExistsException.class, () -> {
defaultRefreshService.refresh(request, response);
Expand All @@ -116,7 +116,7 @@ public void TestRefreshFailed_BothTokenNotFound() {
HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
MockHttpServletResponse response = new MockHttpServletResponse();

Mockito.when(request.getHeader("Authority")).thenReturn("Bearer validAccessToken");
Mockito.when(request.getHeader("Authorization")).thenReturn("Bearer validAccessToken");

Mockito.when(jwtUtils.checkReIssue(Mockito.anyString())).thenReturn(false);
ResponseEntity<?> responseEntity = defaultRefreshService.refresh(request, response);
Expand Down

0 comments on commit ba1e5d4

Please sign in to comment.