Skip to content

Commit

Permalink
test: authService만 사용하는 테스트를 AuthServiceTest로 이동
Browse files Browse the repository at this point in the history
  • Loading branch information
BackFoxx committed Nov 21, 2023
1 parent f1d7b33 commit d175c3d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 42 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
package edonymyeon.backend.auth.application;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.SoftAssertions.assertSoftly;
import static org.awaitility.Awaitility.await;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import edonymyeon.backend.auth.application.dto.JoinRequest;
import edonymyeon.backend.auth.application.dto.KakaoLoginResponse;
import edonymyeon.backend.auth.application.dto.LoginRequest;
Expand All @@ -32,9 +19,6 @@
import edonymyeon.backend.setting.application.SettingService;
import edonymyeon.backend.support.IntegrationTest;
import jakarta.persistence.EntityManager;

import java.util.List;
import java.util.Optional;
import lombok.RequiredArgsConstructor;
import org.assertj.core.api.SoftAssertions;
import org.junit.jupiter.api.DisplayNameGeneration;
Expand All @@ -45,7 +29,16 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.test.context.jdbc.Sql;

import java.util.List;
import java.util.Optional;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.SoftAssertions.assertSoftly;
import static org.awaitility.Awaitility.await;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.mockito.Mockito.*;

@DisplayNameGeneration(ReplaceUnderscores.class)
@SuppressWarnings("NonAsciiCharacters")
Expand Down Expand Up @@ -243,4 +236,18 @@ class AuthServiceTest {
}
);
}

@Test
void 동일한_디바이스_정보가_여러_회원에_걸쳐_존재할_때에도_로그아웃이_정상_동작해야_한다() {
// Given : 회원이 새로 가입하여 로그인한 후 로그아웃한다.
authService.joinMember(new JoinRequest(("[email protected]"), "password123!", "nickname", "sameDevice"));
authService.login(new LoginRequest("[email protected]", "password123!", "sameDevice"));
authService.logout("sameDevice");

// When : 동일한 디바이스를 가지고 새로운 회원이 가입하여 로그인한 후 로그아웃한다.
authService.joinMember(new JoinRequest(("[email protected]"), "password123!", "nickname2", "sameDevice"));
authService.login(new LoginRequest("[email protected]", "password123!", "sameDevice"));
assertThatCode(() -> authService.logout("sameDevice"))
.doesNotThrowAnyException();
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
package edonymyeon.backend.member.application;

import static org.assertj.core.api.Assertions.*;
import static org.assertj.core.api.SoftAssertions.assertSoftly;
import static org.awaitility.Awaitility.await;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.verify;

import edonymyeon.backend.auth.application.AuthService;
import edonymyeon.backend.auth.application.dto.JoinRequest;
import edonymyeon.backend.auth.application.dto.KakaoLoginResponse;
Expand All @@ -21,15 +13,21 @@
import edonymyeon.backend.member.repository.MemberRepository;
import edonymyeon.backend.post.ImageFileCleaner;
import edonymyeon.backend.support.IntegrationFixture;
import java.io.IOException;
import lombok.RequiredArgsConstructor;
import org.assertj.core.api.SoftAssertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.mock.web.MockMultipartFile;

import java.io.IOException;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.SoftAssertions.assertSoftly;
import static org.awaitility.Awaitility.await;
import static org.mockito.Mockito.*;

@SuppressWarnings("NonAsciiCharacters")
@RequiredArgsConstructor
class MemberServiceTest extends IntegrationFixture implements ImageFileCleaner {
Expand Down Expand Up @@ -222,19 +220,4 @@ class MemberServiceTest extends IntegrationFixture implements ImageFileCleaner {
}
);
}

@Test
@DisplayName("동일한 디바이스 정보가 여러 회원에 걸쳐 존재할 때에도 로그아웃이 정상 동작해야 한다.")
void deviceLogoutBug() {
// Given : 회원이 새로 가입하여 로그인한 후 로그아웃한다.
authService.joinMember(new JoinRequest(("[email protected]"), "password123!", "nickname", "sameDevice"));
authService.login(new LoginRequest("[email protected]", "password123!", "sameDevice"));
authService.logout("sameDevice");

// When : 동일한 디바이스를 가지고 새로운 회원이 가입하여 로그인한 후 로그아웃한다.
authService.joinMember(new JoinRequest(("[email protected]"), "password123!", "nickname2", "sameDevice"));
authService.login(new LoginRequest("[email protected]", "password123!", "sameDevice"));
assertThatCode(() -> authService.logout("sameDevice"))
.doesNotThrowAnyException();
}
}

0 comments on commit d175c3d

Please sign in to comment.