Skip to content

Commit

Permalink
Test : 회원탈퇴 테스트
Browse files Browse the repository at this point in the history
  • Loading branch information
Astin01 committed Oct 16, 2024
1 parent a445ff8 commit 87bf74a
Showing 1 changed file with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,36 @@ void reissueRefreshToken() throws Exception {
);
}

@DisplayName("회원탈퇴")
@Test
void deleteUser() throws Exception {
Cookie accessCookie = new MockCookie("access_token", "accessToken");
Cookie refreshCookie = new MockCookie("refresh_token", "refreshToken");
passLogin();
BDDMockito.given(kakaoConnector.refreshToken(any()))
.willReturn("refreshToken");

doNothing().when(oauthService).revokeToken("kakao", "refreshToken");
doNothing().when(oauthService).logout(any(), any());
doNothing().when(oauthService).deleteUser(1L);

mockMvc.perform(delete("/api/auth/oauth2")
.queryParam("type", "kakao")
.cookie(accessCookie)
.cookie(refreshCookie)
)
.andExpectAll(
status().isNoContent()
)
.andDo(
document("oauthDelete",
preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint())
)
);
}


@DisplayName("Oauth 타입이 존재하지 않는경우 404코드가 반환된다")
@Test
void unsupportedLoginType() throws Exception {
Expand Down Expand Up @@ -246,4 +276,18 @@ private void passRefreshLogin(Cookie accessCookie) {
.willReturn(Optional.of(token));
}

private void passLogin() {
User user = User.builder()
.oauthId("oauthId")
.build();
Token token = new Token(user, "accessToken");

BDDMockito.given(jwtTokenProvider.validateTokenNotUsable(any()))
.willReturn(false);
BDDMockito.given(jwtTokenProvider.getPayload(any()))
.willReturn(1L);
BDDMockito.given(tokenRepository.findByUserId(1L))
.willReturn(Optional.of(token));
}

}

0 comments on commit 87bf74a

Please sign in to comment.