-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#83] test : 카카오 아이디로 회원가입이 되는지 테스트 한다
- Loading branch information
1 parent
e9045fa
commit 89ad8bd
Showing
8 changed files
with
91 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,21 +3,16 @@ | |
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.Email; | ||
import jakarta.validation.constraints.NotBlank; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Schema(title = "카카오 로그인 및 회원가입") | ||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class KakaoLogin { | ||
public record KakaoLoginRequest( | ||
@NotBlank(message = "이메일을 입력해주세요.") | ||
@Email(message = "올바른 이메일 주소를 입력해주세요.") | ||
@Schema(description = "이메일", example = "[email protected]") | ||
private String email; | ||
String email, | ||
|
||
@Schema(description = "providerId", example = "10378247832195") | ||
private String providerId; | ||
String providerId | ||
) { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...auth/entity/CustomUserDetailsService.java → ...uth/service/CustomUserDetailsService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/test/java/ssu/eatssu/domain/auth/service/OauthServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package ssu.eatssu.domain.auth.service; | ||
|
||
import static org.assertj.core.api.Assertions.*; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import ssu.eatssu.domain.auth.dto.KakaoLoginRequest; | ||
import ssu.eatssu.domain.user.entity.User; | ||
import ssu.eatssu.domain.user.repository.UserRepository; | ||
|
||
@SpringBootTest | ||
class OauthServiceTest { | ||
|
||
@Autowired | ||
private OauthService oauthService; | ||
|
||
@Autowired | ||
private UserRepository userRepository; | ||
|
||
@Test | ||
void 카카오로_회원가입을_한다() { | ||
// given | ||
KakaoLoginRequest request = new KakaoLoginRequest("[email protected]", "10378247832195"); | ||
|
||
// when | ||
oauthService.kakaoLogin(request); | ||
User user = userRepository.findByProviderId(request.providerId()).get(); | ||
|
||
// then | ||
assertThat(userRepository.findAll()).hasSize(1); | ||
assertThat(user.getEmail()).isEqualTo(request.email()); | ||
assertThat(user.getProviderId()).isEqualTo(request.providerId()); | ||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
src/test/java/ssu/eatssu/domain/user/service/UserServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package ssu.eatssu.domain.user.service; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import ssu.eatssu.domain.user.repository.UserRepository; | ||
|
||
@SpringBootTest | ||
class UserServiceTest { | ||
|
||
@Autowired | ||
private UserService userService; | ||
@Autowired | ||
private UserRepository userRepository; | ||
|
||
@Test | ||
void 회원_탈퇴_성공시_참을_반환한다() { | ||
// given | ||
|
||
// when | ||
// then | ||
Assertions.assertThat(userRepository.findAll()).hasSize(0); | ||
|
||
} | ||
|
||
} |