From 48c983ceaab3f3ae0a7ba5dd9dcb4fe26ebe1f25 Mon Sep 17 00:00:00 2001 From: Jisu Lim <69844138+Ji-soo708@users.noreply.github.com> Date: Mon, 6 Jan 2025 18:06:18 +0900 Subject: [PATCH] =?UTF-8?q?[YS-32]=20feat:=20Naver=20OAuth=20=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EC=9D=B8=20=EC=B6=94=EA=B0=80=20(#20)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: add feignclient for naver * feat: add FetchNaverUserInfoUseCase logic * test: add FetchNaverUserInfoUseCaseTest * chore: add naver variable to template-application-local.yml * refact: delete unused import and move testcode to appropriate package * refact: refactor NaverUserInfoFeignClient interface * refact: move class file to appropriate package --- .../application/mapper/SignupMapper.kt | 5 +- .../application/service/OauthService.kt | 12 ++- .../application/service/SignupService.kt | 2 +- .../usecase/FetchGoogleUserInfoUseCase.kt | 17 ++--- .../usecase/FetchNaverUserInfoUseCase.kt | 65 ++++++++++++++++ .../usecase/ParticipantSignupUseCase.kt | 2 +- .../config/properties/NaverAuthProperties.kt | 12 +++ .../{ => google}/GoogleAuthFeignClient.kt | 6 +- .../{ => google}/GoogleUserInfoFeginClient.kt | 4 +- .../feign/naver/NaverAuthFeignClient.kt | 18 +++++ .../feign/naver/NaverUserInfoFeignClient.kt | 15 ++++ .../api/controller/AuthController.kt | 20 +++-- .../ParticipantSignupController.kt | 3 +- .../api/dto/request/OauthUserDto.kt | 9 --- .../GoogleOauthLoginRequest.kt} | 6 +- .../request/{ => auth}/GoogleTokenRequest.kt | 2 +- .../{ => auth}/MemberRefreshTokenRequest.kt | 2 +- .../request/auth/NaverOauthLoginRequest.kt | 11 +++ .../api/dto/request/auth/NaverTokenRequest.kt | 20 +++++ .../{ => signup}/ParticipantSignupRequest.kt | 2 +- .../auth/{google => }/GoogleInfoResponse.kt | 2 +- .../auth/{google => }/GoogleTokenResponse.kt | 2 +- .../dto/response/auth/NaverInfoResponse.kt | 11 +++ .../dto/response/auth/NaverTokenResponse.kt | 8 ++ .../{ => auth}/TestMemberSignInResponse.kt | 2 +- src/main/resources/application.yml | 15 ++++ .../resources/template-application-local.yml | 31 ++++++++ .../application/mapper/SignupMapperTest.kt | 4 +- .../application/service/OauthServiceTest.kt | 9 ++- .../usecase/FetchGoogleUserInfoTest.kt | 10 +-- .../usecase/FetchNaverUserInfoTest.kt | 74 +++++++++++++++++++ .../usecase/ParticipantSignupUseCaseTest.kt | 7 +- 32 files changed, 348 insertions(+), 60 deletions(-) create mode 100644 src/main/kotlin/com/dobby/backend/application/usecase/FetchNaverUserInfoUseCase.kt create mode 100644 src/main/kotlin/com/dobby/backend/infrastructure/config/properties/NaverAuthProperties.kt rename src/main/kotlin/com/dobby/backend/infrastructure/feign/{ => google}/GoogleAuthFeignClient.kt (67%) rename src/main/kotlin/com/dobby/backend/infrastructure/feign/{ => google}/GoogleUserInfoFeginClient.kt (77%) create mode 100644 src/main/kotlin/com/dobby/backend/infrastructure/feign/naver/NaverAuthFeignClient.kt create mode 100644 src/main/kotlin/com/dobby/backend/infrastructure/feign/naver/NaverUserInfoFeignClient.kt delete mode 100644 src/main/kotlin/com/dobby/backend/presentation/api/dto/request/OauthUserDto.kt rename src/main/kotlin/com/dobby/backend/presentation/api/dto/request/{OauthLoginRequest.kt => auth/GoogleOauthLoginRequest.kt} (61%) rename src/main/kotlin/com/dobby/backend/presentation/api/dto/request/{ => auth}/GoogleTokenRequest.kt (87%) rename src/main/kotlin/com/dobby/backend/presentation/api/dto/request/{ => auth}/MemberRefreshTokenRequest.kt (83%) create mode 100644 src/main/kotlin/com/dobby/backend/presentation/api/dto/request/auth/NaverOauthLoginRequest.kt create mode 100644 src/main/kotlin/com/dobby/backend/presentation/api/dto/request/auth/NaverTokenRequest.kt rename src/main/kotlin/com/dobby/backend/presentation/api/dto/request/{ => signup}/ParticipantSignupRequest.kt (96%) rename src/main/kotlin/com/dobby/backend/presentation/api/dto/response/auth/{google => }/GoogleInfoResponse.kt (73%) rename src/main/kotlin/com/dobby/backend/presentation/api/dto/response/auth/{google => }/GoogleTokenResponse.kt (68%) create mode 100644 src/main/kotlin/com/dobby/backend/presentation/api/dto/response/auth/NaverInfoResponse.kt create mode 100644 src/main/kotlin/com/dobby/backend/presentation/api/dto/response/auth/NaverTokenResponse.kt rename src/main/kotlin/com/dobby/backend/presentation/api/dto/response/{ => auth}/TestMemberSignInResponse.kt (83%) create mode 100644 src/test/kotlin/com/dobby/backend/application/usecase/FetchNaverUserInfoTest.kt diff --git a/src/main/kotlin/com/dobby/backend/application/mapper/SignupMapper.kt b/src/main/kotlin/com/dobby/backend/application/mapper/SignupMapper.kt index aa1e308..3307970 100644 --- a/src/main/kotlin/com/dobby/backend/application/mapper/SignupMapper.kt +++ b/src/main/kotlin/com/dobby/backend/application/mapper/SignupMapper.kt @@ -4,10 +4,9 @@ import com.dobby.backend.infrastructure.database.entity.MemberEntity import com.dobby.backend.infrastructure.database.entity.ParticipantEntity import com.dobby.backend.infrastructure.database.entity.enum.MemberStatus import com.dobby.backend.infrastructure.database.entity.enum.RoleType -import com.dobby.backend.presentation.api.dto.request.ParticipantSignupRequest -import com.dobby.backend.presentation.api.dto.response.MemberResponse +import com.dobby.backend.presentation.api.dto.request.signup.ParticipantSignupRequest import com.dobby.backend.infrastructure.database.entity.AddressInfo as AddressInfo -import com.dobby.backend.presentation.api.dto.request.AddressInfo as DtoAddressInfo +import com.dobby.backend.presentation.api.dto.request.signup.AddressInfo as DtoAddressInfo object SignupMapper { fun toAddressInfo(dto: DtoAddressInfo): AddressInfo { diff --git a/src/main/kotlin/com/dobby/backend/application/service/OauthService.kt b/src/main/kotlin/com/dobby/backend/application/service/OauthService.kt index 7d136f1..48b4141 100644 --- a/src/main/kotlin/com/dobby/backend/application/service/OauthService.kt +++ b/src/main/kotlin/com/dobby/backend/application/service/OauthService.kt @@ -1,16 +1,22 @@ package com.dobby.backend.application.service import com.dobby.backend.application.usecase.FetchGoogleUserInfoUseCase -import com.dobby.backend.presentation.api.dto.request.OauthLoginRequest +import com.dobby.backend.application.usecase.FetchNaverUserInfoUseCase +import com.dobby.backend.presentation.api.dto.request.auth.GoogleOauthLoginRequest +import com.dobby.backend.presentation.api.dto.request.auth.NaverOauthLoginRequest import com.dobby.backend.presentation.api.dto.response.auth.OauthLoginResponse import org.springframework.stereotype.Service @Service class OauthService( - private val fetchGoogleUserInfoUseCase: FetchGoogleUserInfoUseCase + private val fetchGoogleUserInfoUseCase: FetchGoogleUserInfoUseCase, + private val fetchNaverUserInfoUseCase: FetchNaverUserInfoUseCase, ) { - fun getGoogleUserInfo(oauthLoginRequest: OauthLoginRequest): OauthLoginResponse { + fun getGoogleUserInfo(oauthLoginRequest: GoogleOauthLoginRequest): OauthLoginResponse { return fetchGoogleUserInfoUseCase.execute(oauthLoginRequest) } + fun getNaverUserInfo(oauthLoginRequest: NaverOauthLoginRequest): OauthLoginResponse { + return fetchNaverUserInfoUseCase.execute(oauthLoginRequest) + } } diff --git a/src/main/kotlin/com/dobby/backend/application/service/SignupService.kt b/src/main/kotlin/com/dobby/backend/application/service/SignupService.kt index 3d08f2e..850f6e2 100644 --- a/src/main/kotlin/com/dobby/backend/application/service/SignupService.kt +++ b/src/main/kotlin/com/dobby/backend/application/service/SignupService.kt @@ -1,7 +1,7 @@ package com.dobby.backend.application.service import com.dobby.backend.application.usecase.ParticipantSignupUseCase -import com.dobby.backend.presentation.api.dto.request.ParticipantSignupRequest +import com.dobby.backend.presentation.api.dto.request.signup.ParticipantSignupRequest import com.dobby.backend.presentation.api.dto.response.signup.SignupResponse import jakarta.transaction.Transactional import org.springframework.stereotype.Service diff --git a/src/main/kotlin/com/dobby/backend/application/usecase/FetchGoogleUserInfoUseCase.kt b/src/main/kotlin/com/dobby/backend/application/usecase/FetchGoogleUserInfoUseCase.kt index 79f453a..1a2bd9a 100644 --- a/src/main/kotlin/com/dobby/backend/application/usecase/FetchGoogleUserInfoUseCase.kt +++ b/src/main/kotlin/com/dobby/backend/application/usecase/FetchGoogleUserInfoUseCase.kt @@ -1,18 +1,17 @@ package com.dobby.backend.application.usecase import com.dobby.backend.application.mapper.OauthUserMapper -import com.dobby.backend.domain.exception.OAuth2EmailNotFoundException import com.dobby.backend.domain.exception.SignInMemberException import com.dobby.backend.infrastructure.config.properties.GoogleAuthProperties import com.dobby.backend.infrastructure.database.entity.enum.MemberStatus import com.dobby.backend.infrastructure.database.entity.enum.ProviderType import com.dobby.backend.infrastructure.database.repository.MemberRepository -import com.dobby.backend.infrastructure.feign.GoogleAuthFeignClient -import com.dobby.backend.infrastructure.feign.GoogleUserInfoFeginClient +import com.dobby.backend.infrastructure.feign.google.GoogleAuthFeignClient +import com.dobby.backend.infrastructure.feign.google.GoogleUserInfoFeginClient import com.dobby.backend.infrastructure.token.JwtTokenProvider -import com.dobby.backend.presentation.api.dto.request.GoogleTokenRequest -import com.dobby.backend.presentation.api.dto.request.OauthLoginRequest -import com.dobby.backend.presentation.api.dto.response.auth.google.GoogleTokenResponse +import com.dobby.backend.presentation.api.dto.request.auth.GoogleOauthLoginRequest +import com.dobby.backend.presentation.api.dto.request.auth.GoogleTokenRequest +import com.dobby.backend.presentation.api.dto.response.auth.GoogleTokenResponse import com.dobby.backend.presentation.api.dto.response.auth.OauthLoginResponse import com.dobby.backend.util.AuthenticationUtils @@ -22,9 +21,9 @@ class FetchGoogleUserInfoUseCase( private val jwtTokenProvider: JwtTokenProvider, private val googleAuthProperties: GoogleAuthProperties, private val memberRepository: MemberRepository -) : UseCase { +) : UseCase { - override fun execute(input: OauthLoginRequest): OauthLoginResponse { + override fun execute(input: GoogleOauthLoginRequest): OauthLoginResponse { try { val googleTokenRequest = GoogleTokenRequest( code = input.authorizationCode, @@ -37,7 +36,7 @@ class FetchGoogleUserInfoUseCase( val oauthToken = oauthRes.accessToken val userInfo = googleUserInfoFeginClient.getUserInfo("Bearer $oauthToken") - val email = userInfo.email ?: throw OAuth2EmailNotFoundException() + val email = userInfo.email val regMember = memberRepository.findByOauthEmailAndStatus(email, MemberStatus.ACTIVE) ?: throw SignInMemberException() diff --git a/src/main/kotlin/com/dobby/backend/application/usecase/FetchNaverUserInfoUseCase.kt b/src/main/kotlin/com/dobby/backend/application/usecase/FetchNaverUserInfoUseCase.kt new file mode 100644 index 0000000..3158135 --- /dev/null +++ b/src/main/kotlin/com/dobby/backend/application/usecase/FetchNaverUserInfoUseCase.kt @@ -0,0 +1,65 @@ +package com.dobby.backend.application.usecase + +import com.dobby.backend.application.mapper.OauthUserMapper +import com.dobby.backend.domain.exception.SignInMemberException +import com.dobby.backend.infrastructure.config.properties.NaverAuthProperties +import com.dobby.backend.infrastructure.database.entity.enum.MemberStatus +import com.dobby.backend.infrastructure.database.entity.enum.ProviderType +import com.dobby.backend.infrastructure.database.repository.MemberRepository +import com.dobby.backend.infrastructure.feign.naver.NaverAuthFeignClient +import com.dobby.backend.infrastructure.feign.naver.NaverUserInfoFeignClient +import com.dobby.backend.infrastructure.token.JwtTokenProvider +import com.dobby.backend.presentation.api.dto.request.auth.NaverOauthLoginRequest +import com.dobby.backend.presentation.api.dto.request.auth.NaverTokenRequest +import com.dobby.backend.presentation.api.dto.response.auth.NaverTokenResponse +import com.dobby.backend.presentation.api.dto.response.auth.OauthLoginResponse +import com.dobby.backend.util.AuthenticationUtils + +class FetchNaverUserInfoUseCase( + private val naverAuthFeignClient: NaverAuthFeignClient, + private val naverUserInfoFeginClient: NaverUserInfoFeignClient, + private val jwtTokenProvider: JwtTokenProvider, + private val naverAuthProperties: NaverAuthProperties, + private val memberRepository: MemberRepository +) : UseCase { + + override fun execute(input: NaverOauthLoginRequest): OauthLoginResponse { + try { + val naverTokenRequest = NaverTokenRequest( + grantType = "authorization_code", + clientId = naverAuthProperties.clientId, + clientSecret = naverAuthProperties.clientSecret, + code = input.authorizationCode, + state = input.state + ) + + val oauthRes = fetchAccessToken(naverTokenRequest) + val oauthToken = oauthRes.accessToken + + val userInfo = naverUserInfoFeginClient.getUserInfo("Bearer $oauthToken") + val email = userInfo.email + val regMember = memberRepository.findByOauthEmailAndStatus(email, MemberStatus.ACTIVE) + ?: throw SignInMemberException() + + val regMemberAuthentication = AuthenticationUtils.createAuthentication(regMember) + val jwtAccessToken = jwtTokenProvider.generateAccessToken(regMemberAuthentication) + val jwtRefreshToken = jwtTokenProvider.generateRefreshToken(regMemberAuthentication) + + return OauthUserMapper.toDto( + isRegistered = true, + accessToken = jwtAccessToken, + refreshToken = jwtRefreshToken, + oauthEmail = regMember.oauthEmail, + oauthName = regMember.name ?: throw SignInMemberException(), + role = regMember.role ?: throw SignInMemberException(), + provider = ProviderType.NAVER + ) + } catch (e: SignInMemberException) { + throw SignInMemberException() + } + } + + private fun fetchAccessToken(naverTokenRequest: NaverTokenRequest): NaverTokenResponse { + return naverAuthFeignClient.getAccessToken(naverTokenRequest) + } +} diff --git a/src/main/kotlin/com/dobby/backend/application/usecase/ParticipantSignupUseCase.kt b/src/main/kotlin/com/dobby/backend/application/usecase/ParticipantSignupUseCase.kt index 69185d7..ceaec53 100644 --- a/src/main/kotlin/com/dobby/backend/application/usecase/ParticipantSignupUseCase.kt +++ b/src/main/kotlin/com/dobby/backend/application/usecase/ParticipantSignupUseCase.kt @@ -3,7 +3,7 @@ package com.dobby.backend.application.usecase import com.dobby.backend.application.mapper.SignupMapper import com.dobby.backend.infrastructure.database.repository.ParticipantRepository import com.dobby.backend.infrastructure.token.JwtTokenProvider -import com.dobby.backend.presentation.api.dto.request.ParticipantSignupRequest +import com.dobby.backend.presentation.api.dto.request.signup.ParticipantSignupRequest import com.dobby.backend.presentation.api.dto.response.MemberResponse import com.dobby.backend.presentation.api.dto.response.signup.SignupResponse import com.dobby.backend.util.AuthenticationUtils diff --git a/src/main/kotlin/com/dobby/backend/infrastructure/config/properties/NaverAuthProperties.kt b/src/main/kotlin/com/dobby/backend/infrastructure/config/properties/NaverAuthProperties.kt new file mode 100644 index 0000000..ed583c5 --- /dev/null +++ b/src/main/kotlin/com/dobby/backend/infrastructure/config/properties/NaverAuthProperties.kt @@ -0,0 +1,12 @@ +package com.dobby.backend.infrastructure.config.properties + +import org.springframework.boot.context.properties.ConfigurationProperties +import org.springframework.stereotype.Component + +@Component +@ConfigurationProperties(prefix = "spring.security.oauth.client.registration.naver") +data class NaverAuthProperties ( + var clientId: String = "", + var clientSecret: String= "", + var redirectUri : String = "" +) diff --git a/src/main/kotlin/com/dobby/backend/infrastructure/feign/GoogleAuthFeignClient.kt b/src/main/kotlin/com/dobby/backend/infrastructure/feign/google/GoogleAuthFeignClient.kt similarity index 67% rename from src/main/kotlin/com/dobby/backend/infrastructure/feign/GoogleAuthFeignClient.kt rename to src/main/kotlin/com/dobby/backend/infrastructure/feign/google/GoogleAuthFeignClient.kt index aa0ed62..014e7f1 100644 --- a/src/main/kotlin/com/dobby/backend/infrastructure/feign/GoogleAuthFeignClient.kt +++ b/src/main/kotlin/com/dobby/backend/infrastructure/feign/google/GoogleAuthFeignClient.kt @@ -1,7 +1,7 @@ -package com.dobby.backend.infrastructure.feign +package com.dobby.backend.infrastructure.feign.google -import com.dobby.backend.presentation.api.dto.request.GoogleTokenRequest -import com.dobby.backend.presentation.api.dto.response.auth.google.GoogleTokenResponse +import com.dobby.backend.presentation.api.dto.request.auth.GoogleTokenRequest +import com.dobby.backend.presentation.api.dto.response.auth.GoogleTokenResponse import org.springframework.cloud.openfeign.FeignClient import org.springframework.web.bind.annotation.PostMapping import org.springframework.web.bind.annotation.RequestBody diff --git a/src/main/kotlin/com/dobby/backend/infrastructure/feign/GoogleUserInfoFeginClient.kt b/src/main/kotlin/com/dobby/backend/infrastructure/feign/google/GoogleUserInfoFeginClient.kt similarity index 77% rename from src/main/kotlin/com/dobby/backend/infrastructure/feign/GoogleUserInfoFeginClient.kt rename to src/main/kotlin/com/dobby/backend/infrastructure/feign/google/GoogleUserInfoFeginClient.kt index 6c26b6a..deafd51 100644 --- a/src/main/kotlin/com/dobby/backend/infrastructure/feign/GoogleUserInfoFeginClient.kt +++ b/src/main/kotlin/com/dobby/backend/infrastructure/feign/google/GoogleUserInfoFeginClient.kt @@ -1,6 +1,6 @@ -package com.dobby.backend.infrastructure.feign +package com.dobby.backend.infrastructure.feign.google -import com.dobby.backend.presentation.api.dto.response.auth.google.GoogleInfoResponse +import com.dobby.backend.presentation.api.dto.response.auth.GoogleInfoResponse import org.springframework.cloud.openfeign.FeignClient import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.PathVariable diff --git a/src/main/kotlin/com/dobby/backend/infrastructure/feign/naver/NaverAuthFeignClient.kt b/src/main/kotlin/com/dobby/backend/infrastructure/feign/naver/NaverAuthFeignClient.kt new file mode 100644 index 0000000..ecd49d1 --- /dev/null +++ b/src/main/kotlin/com/dobby/backend/infrastructure/feign/naver/NaverAuthFeignClient.kt @@ -0,0 +1,18 @@ +package com.dobby.backend.infrastructure.feign.naver + +import com.dobby.backend.presentation.api.dto.request.auth.NaverTokenRequest +import com.dobby.backend.presentation.api.dto.response.auth.NaverTokenResponse +import org.springframework.cloud.openfeign.FeignClient +import org.springframework.web.bind.annotation.PostMapping +import org.springframework.web.bind.annotation.RequestBody + +@FeignClient( + name = "naver-auth-feign-client", + url = "https://nid.naver.com/oauth2.0/token" +) +interface NaverAuthFeignClient { + @PostMapping + fun getAccessToken( + @RequestBody naverTokenRequest: NaverTokenRequest + ): NaverTokenResponse +} diff --git a/src/main/kotlin/com/dobby/backend/infrastructure/feign/naver/NaverUserInfoFeignClient.kt b/src/main/kotlin/com/dobby/backend/infrastructure/feign/naver/NaverUserInfoFeignClient.kt new file mode 100644 index 0000000..b209656 --- /dev/null +++ b/src/main/kotlin/com/dobby/backend/infrastructure/feign/naver/NaverUserInfoFeignClient.kt @@ -0,0 +1,15 @@ +package com.dobby.backend.infrastructure.feign.naver + +import com.dobby.backend.presentation.api.dto.response.auth.NaverInfoResponse +import org.springframework.cloud.openfeign.FeignClient +import org.springframework.web.bind.annotation.PostMapping +import org.springframework.web.bind.annotation.RequestHeader + +@FeignClient( + name = "naver-userinfo-feign-client", + url = "https://openapi.naver.com/v1/nid/me" +) +interface NaverUserInfoFeignClient { + @PostMapping + fun getUserInfo(@RequestHeader("Authorization") accessToken: String): NaverInfoResponse +} diff --git a/src/main/kotlin/com/dobby/backend/presentation/api/controller/AuthController.kt b/src/main/kotlin/com/dobby/backend/presentation/api/controller/AuthController.kt index 102d358..6fa243a 100644 --- a/src/main/kotlin/com/dobby/backend/presentation/api/controller/AuthController.kt +++ b/src/main/kotlin/com/dobby/backend/presentation/api/controller/AuthController.kt @@ -2,14 +2,15 @@ package com.dobby.backend.presentation.api.controller import com.dobby.backend.application.service.OauthService import com.dobby.backend.application.usecase.GenerateTestToken -import com.dobby.backend.presentation.api.dto.request.OauthLoginRequest import com.dobby.backend.presentation.api.dto.response.auth.OauthLoginResponse import com.dobby.backend.application.usecase.GenerateTokenWithRefreshToken import com.dobby.backend.application.usecase.GetMemberById import com.dobby.backend.infrastructure.database.entity.enum.RoleType -import com.dobby.backend.presentation.api.dto.request.MemberRefreshTokenRequest +import com.dobby.backend.presentation.api.dto.request.auth.GoogleOauthLoginRequest +import com.dobby.backend.presentation.api.dto.request.auth.MemberRefreshTokenRequest +import com.dobby.backend.presentation.api.dto.request.auth.NaverOauthLoginRequest import com.dobby.backend.presentation.api.dto.response.MemberResponse -import com.dobby.backend.presentation.api.dto.response.TestMemberSignInResponse +import com.dobby.backend.presentation.api.dto.response.auth.TestMemberSignInResponse import io.swagger.v3.oas.annotations.Operation import io.swagger.v3.oas.annotations.tags.Tag import jakarta.validation.Valid @@ -42,12 +43,21 @@ class AuthController( @PostMapping("/login/google") @Operation(summary = "Google OAuth 로그인 API", description = "Google OAuth 로그인 후 인증 정보를 반환합니다") fun signInWithGoogle( - @RequestParam role : RoleType, // RESEARCHER, PARTICIPANT - @RequestBody @Valid oauthLoginRequest: OauthLoginRequest + @RequestParam role : RoleType, + @RequestBody @Valid oauthLoginRequest: GoogleOauthLoginRequest ): OauthLoginResponse { return oauthService.getGoogleUserInfo(oauthLoginRequest) } + @PostMapping("/login/naver") + @Operation(summary = "Naver OAuth 로그인 API", description = "Naver OAuth 로그인 후 인증 정보를 반환합니다") + fun signInWithNaver( + @RequestParam role : RoleType, + @RequestBody @Valid oauthLoginRequest: NaverOauthLoginRequest + ): OauthLoginResponse { + return oauthService.getNaverUserInfo(oauthLoginRequest) + } + @Operation(summary = "토큰 갱신 요청", description = "리프레시 토큰으로 기존 토큰을 갱신합니다") @PostMapping("/refresh") fun signInWithRefreshToken( diff --git a/src/main/kotlin/com/dobby/backend/presentation/api/controller/SignupController/ParticipantSignupController.kt b/src/main/kotlin/com/dobby/backend/presentation/api/controller/SignupController/ParticipantSignupController.kt index 619b66f..d50ef77 100644 --- a/src/main/kotlin/com/dobby/backend/presentation/api/controller/SignupController/ParticipantSignupController.kt +++ b/src/main/kotlin/com/dobby/backend/presentation/api/controller/SignupController/ParticipantSignupController.kt @@ -1,9 +1,8 @@ package com.dobby.backend.presentation.api.controller.SignupController import com.dobby.backend.application.service.SignupService -import com.dobby.backend.infrastructure.database.entity.enum.RoleType import com.dobby.backend.infrastructure.database.entity.enum.RoleType.* -import com.dobby.backend.presentation.api.dto.request.ParticipantSignupRequest +import com.dobby.backend.presentation.api.dto.request.signup.ParticipantSignupRequest import com.dobby.backend.presentation.api.dto.response.signup.SignupResponse import io.swagger.v3.oas.annotations.Operation import io.swagger.v3.oas.annotations.tags.Tag diff --git a/src/main/kotlin/com/dobby/backend/presentation/api/dto/request/OauthUserDto.kt b/src/main/kotlin/com/dobby/backend/presentation/api/dto/request/OauthUserDto.kt deleted file mode 100644 index 79837c1..0000000 --- a/src/main/kotlin/com/dobby/backend/presentation/api/dto/request/OauthUserDto.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.dobby.backend.presentation.api.dto.request - -import com.dobby.backend.infrastructure.database.entity.enum.ProviderType - -data class OauthUserDto( - val email: String, - val name: String, - val provider: ProviderType -) diff --git a/src/main/kotlin/com/dobby/backend/presentation/api/dto/request/OauthLoginRequest.kt b/src/main/kotlin/com/dobby/backend/presentation/api/dto/request/auth/GoogleOauthLoginRequest.kt similarity index 61% rename from src/main/kotlin/com/dobby/backend/presentation/api/dto/request/OauthLoginRequest.kt rename to src/main/kotlin/com/dobby/backend/presentation/api/dto/request/auth/GoogleOauthLoginRequest.kt index 482fccb..54d3213 100644 --- a/src/main/kotlin/com/dobby/backend/presentation/api/dto/request/OauthLoginRequest.kt +++ b/src/main/kotlin/com/dobby/backend/presentation/api/dto/request/auth/GoogleOauthLoginRequest.kt @@ -1,8 +1,8 @@ -package com.dobby.backend.presentation.api.dto.request +package com.dobby.backend.presentation.api.dto.request.auth import jakarta.validation.constraints.NotBlank -data class OauthLoginRequest( +data class GoogleOauthLoginRequest( @NotBlank(message = "authorizationCode는 공백일 수 없습니다.") val authorizationCode: String -) \ No newline at end of file +) diff --git a/src/main/kotlin/com/dobby/backend/presentation/api/dto/request/GoogleTokenRequest.kt b/src/main/kotlin/com/dobby/backend/presentation/api/dto/request/auth/GoogleTokenRequest.kt similarity index 87% rename from src/main/kotlin/com/dobby/backend/presentation/api/dto/request/GoogleTokenRequest.kt rename to src/main/kotlin/com/dobby/backend/presentation/api/dto/request/auth/GoogleTokenRequest.kt index 803e7b1..22d5455 100644 --- a/src/main/kotlin/com/dobby/backend/presentation/api/dto/request/GoogleTokenRequest.kt +++ b/src/main/kotlin/com/dobby/backend/presentation/api/dto/request/auth/GoogleTokenRequest.kt @@ -1,4 +1,4 @@ -package com.dobby.backend.presentation.api.dto.request +package com.dobby.backend.presentation.api.dto.request.auth import com.fasterxml.jackson.annotation.JsonProperty diff --git a/src/main/kotlin/com/dobby/backend/presentation/api/dto/request/MemberRefreshTokenRequest.kt b/src/main/kotlin/com/dobby/backend/presentation/api/dto/request/auth/MemberRefreshTokenRequest.kt similarity index 83% rename from src/main/kotlin/com/dobby/backend/presentation/api/dto/request/MemberRefreshTokenRequest.kt rename to src/main/kotlin/com/dobby/backend/presentation/api/dto/request/auth/MemberRefreshTokenRequest.kt index 1401eae..63094fc 100644 --- a/src/main/kotlin/com/dobby/backend/presentation/api/dto/request/MemberRefreshTokenRequest.kt +++ b/src/main/kotlin/com/dobby/backend/presentation/api/dto/request/auth/MemberRefreshTokenRequest.kt @@ -1,4 +1,4 @@ -package com.dobby.backend.presentation.api.dto.request +package com.dobby.backend.presentation.api.dto.request.auth import io.swagger.v3.oas.annotations.media.Schema import jakarta.validation.constraints.NotBlank diff --git a/src/main/kotlin/com/dobby/backend/presentation/api/dto/request/auth/NaverOauthLoginRequest.kt b/src/main/kotlin/com/dobby/backend/presentation/api/dto/request/auth/NaverOauthLoginRequest.kt new file mode 100644 index 0000000..72d52a5 --- /dev/null +++ b/src/main/kotlin/com/dobby/backend/presentation/api/dto/request/auth/NaverOauthLoginRequest.kt @@ -0,0 +1,11 @@ +package com.dobby.backend.presentation.api.dto.request.auth + +import jakarta.validation.constraints.NotBlank + +data class NaverOauthLoginRequest( + @NotBlank(message = "authorizationCode는 공백일 수 없습니다.") + val authorizationCode: String, + + @NotBlank(message = "state는 공백일 수 없습니다.") + val state: String, +) diff --git a/src/main/kotlin/com/dobby/backend/presentation/api/dto/request/auth/NaverTokenRequest.kt b/src/main/kotlin/com/dobby/backend/presentation/api/dto/request/auth/NaverTokenRequest.kt new file mode 100644 index 0000000..932092f --- /dev/null +++ b/src/main/kotlin/com/dobby/backend/presentation/api/dto/request/auth/NaverTokenRequest.kt @@ -0,0 +1,20 @@ +package com.dobby.backend.presentation.api.dto.request.auth + +import com.fasterxml.jackson.annotation.JsonProperty + +data class NaverTokenRequest ( + @JsonProperty("grant_type") + val grantType: String = "authorization_code", + + @JsonProperty("client_id") + val clientId: String, + + @JsonProperty("client_secret") + val clientSecret: String, + + @JsonProperty("code") + val code: String, + + @JsonProperty("state") + val state: String +) \ No newline at end of file diff --git a/src/main/kotlin/com/dobby/backend/presentation/api/dto/request/ParticipantSignupRequest.kt b/src/main/kotlin/com/dobby/backend/presentation/api/dto/request/signup/ParticipantSignupRequest.kt similarity index 96% rename from src/main/kotlin/com/dobby/backend/presentation/api/dto/request/ParticipantSignupRequest.kt rename to src/main/kotlin/com/dobby/backend/presentation/api/dto/request/signup/ParticipantSignupRequest.kt index eb45320..c640d65 100644 --- a/src/main/kotlin/com/dobby/backend/presentation/api/dto/request/ParticipantSignupRequest.kt +++ b/src/main/kotlin/com/dobby/backend/presentation/api/dto/request/signup/ParticipantSignupRequest.kt @@ -1,4 +1,4 @@ -package com.dobby.backend.presentation.api.dto.request +package com.dobby.backend.presentation.api.dto.request.signup import com.dobby.backend.infrastructure.database.entity.enum.GenderType import com.dobby.backend.infrastructure.database.entity.enum.MatchType diff --git a/src/main/kotlin/com/dobby/backend/presentation/api/dto/response/auth/google/GoogleInfoResponse.kt b/src/main/kotlin/com/dobby/backend/presentation/api/dto/response/auth/GoogleInfoResponse.kt similarity index 73% rename from src/main/kotlin/com/dobby/backend/presentation/api/dto/response/auth/google/GoogleInfoResponse.kt rename to src/main/kotlin/com/dobby/backend/presentation/api/dto/response/auth/GoogleInfoResponse.kt index 46652cd..ea50e2d 100644 --- a/src/main/kotlin/com/dobby/backend/presentation/api/dto/response/auth/google/GoogleInfoResponse.kt +++ b/src/main/kotlin/com/dobby/backend/presentation/api/dto/response/auth/GoogleInfoResponse.kt @@ -1,4 +1,4 @@ -package com.dobby.backend.presentation.api.dto.response.auth.google +package com.dobby.backend.presentation.api.dto.response.auth import com.fasterxml.jackson.annotation.JsonProperty diff --git a/src/main/kotlin/com/dobby/backend/presentation/api/dto/response/auth/google/GoogleTokenResponse.kt b/src/main/kotlin/com/dobby/backend/presentation/api/dto/response/auth/GoogleTokenResponse.kt similarity index 68% rename from src/main/kotlin/com/dobby/backend/presentation/api/dto/response/auth/google/GoogleTokenResponse.kt rename to src/main/kotlin/com/dobby/backend/presentation/api/dto/response/auth/GoogleTokenResponse.kt index 59852ce..e2cbe59 100644 --- a/src/main/kotlin/com/dobby/backend/presentation/api/dto/response/auth/google/GoogleTokenResponse.kt +++ b/src/main/kotlin/com/dobby/backend/presentation/api/dto/response/auth/GoogleTokenResponse.kt @@ -1,4 +1,4 @@ -package com.dobby.backend.presentation.api.dto.response.auth.google +package com.dobby.backend.presentation.api.dto.response.auth import com.fasterxml.jackson.annotation.JsonProperty diff --git a/src/main/kotlin/com/dobby/backend/presentation/api/dto/response/auth/NaverInfoResponse.kt b/src/main/kotlin/com/dobby/backend/presentation/api/dto/response/auth/NaverInfoResponse.kt new file mode 100644 index 0000000..e1ab281 --- /dev/null +++ b/src/main/kotlin/com/dobby/backend/presentation/api/dto/response/auth/NaverInfoResponse.kt @@ -0,0 +1,11 @@ +package com.dobby.backend.presentation.api.dto.response.auth + +import com.fasterxml.jackson.annotation.JsonProperty + +data class NaverInfoResponse( + @JsonProperty("email") + val email: String, + + @JsonProperty("name") + val name: String +) diff --git a/src/main/kotlin/com/dobby/backend/presentation/api/dto/response/auth/NaverTokenResponse.kt b/src/main/kotlin/com/dobby/backend/presentation/api/dto/response/auth/NaverTokenResponse.kt new file mode 100644 index 0000000..873f164 --- /dev/null +++ b/src/main/kotlin/com/dobby/backend/presentation/api/dto/response/auth/NaverTokenResponse.kt @@ -0,0 +1,8 @@ +package com.dobby.backend.presentation.api.dto.response.auth + +import com.fasterxml.jackson.annotation.JsonProperty + +data class NaverTokenResponse ( + @JsonProperty("access_token") + val accessToken: String? +) diff --git a/src/main/kotlin/com/dobby/backend/presentation/api/dto/response/TestMemberSignInResponse.kt b/src/main/kotlin/com/dobby/backend/presentation/api/dto/response/auth/TestMemberSignInResponse.kt similarity index 83% rename from src/main/kotlin/com/dobby/backend/presentation/api/dto/response/TestMemberSignInResponse.kt rename to src/main/kotlin/com/dobby/backend/presentation/api/dto/response/auth/TestMemberSignInResponse.kt index f22c194..b282f8a 100644 --- a/src/main/kotlin/com/dobby/backend/presentation/api/dto/response/TestMemberSignInResponse.kt +++ b/src/main/kotlin/com/dobby/backend/presentation/api/dto/response/auth/TestMemberSignInResponse.kt @@ -1,4 +1,4 @@ -package com.dobby.backend.presentation.api.dto.response +package com.dobby.backend.presentation.api.dto.response.auth import io.swagger.v3.oas.annotations.media.Schema diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 14c1204..efe7846 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -31,11 +31,26 @@ spring: scope: - email - profile + naver: + redirect-uri: ${NAVER_REDIRECT_URI} + authorization-grant-type: authorization_code + client-id: ${NAVER_CLIENT_ID} + client-secret: ${NAVER_CLIENT_SECRET} + scope: + - email + - profile + client-name: Naver provider: google: authorization-uri: https://accounts.google.com/o/oauth2/auth token-uri: https://oauth2.googleapis.com/token user-info-uri: https://www.googleapis.com/oauth2/v3/userinfo + naver: + authorization-uri: https://nid.naver.com/oauth2.0/authorize + token-uri: https://nid.naver.com/oauth2.0/token + user-info-uri: https://openapi.naver.com/v1/nid/me + user_name_attribute: response + springdoc: swagger-ui: oauth2-redirect-url: ${SWAGGER_REDIRECT_URI} diff --git a/src/main/resources/template-application-local.yml b/src/main/resources/template-application-local.yml index aaf803b..136f913 100644 --- a/src/main/resources/template-application-local.yml +++ b/src/main/resources/template-application-local.yml @@ -13,6 +13,37 @@ spring: enabled: true show_sql: true format_sql: true + security: + oauth2: + client: + registration: + google: + redirect-uri: ${GOOGLE_REDIRECT_URI} + authorization-grant-type: authorization_code + client-id: ${GOOGLE_CLIENT_ID} + client-secret: ${GOOGLE_CLIENT_SECRET} + scope: + - email + - profile + naver: + redirect-uri: ${NAVER_REDIRECT_URI} + authorization-grant-type: authorization_code + client-id: ${NAVER_CLIENT_ID} + client-secret: ${NAVER_CLIENT_SECRET} + scope: + - email + - profile + client-name: Naver + provider: + google: + authorization-uri: https://accounts.google.com/o/oauth2/auth + token-uri: https://oauth2.googleapis.com/token + user-info-uri: https://www.googleapis.com/oauth2/v3/userinfo + naver: + authorization-uri: https://nid.naver.com/oauth2.0/authorize + token-uri: https://nid.naver.com/oauth2.0/token + user-info-uri: https://openapi.naver.com/v1/nid/me + user_name_attribute: response app: token: diff --git a/src/test/kotlin/com/dobby/backend/application/mapper/SignupMapperTest.kt b/src/test/kotlin/com/dobby/backend/application/mapper/SignupMapperTest.kt index 834b5af..6153448 100644 --- a/src/test/kotlin/com/dobby/backend/application/mapper/SignupMapperTest.kt +++ b/src/test/kotlin/com/dobby/backend/application/mapper/SignupMapperTest.kt @@ -3,12 +3,12 @@ package com.dobby.backend.application.mapper import com.dobby.backend.infrastructure.database.entity.enum.* import com.dobby.backend.infrastructure.database.entity.enum.areaInfo.Area import com.dobby.backend.infrastructure.database.entity.enum.areaInfo.Region -import com.dobby.backend.presentation.api.dto.request.ParticipantSignupRequest +import com.dobby.backend.presentation.api.dto.request.signup.ParticipantSignupRequest import org.springframework.test.context.ActiveProfiles import io.kotest.core.spec.style.BehaviorSpec import io.kotest.matchers.shouldBe import java.time.LocalDate -import com.dobby.backend.presentation.api.dto.request.AddressInfo as DtoAddressInfo +import com.dobby.backend.presentation.api.dto.request.signup.AddressInfo as DtoAddressInfo @ActiveProfiles("test") class SignupMapperTest : BehaviorSpec({ diff --git a/src/test/kotlin/com/dobby/backend/application/service/OauthServiceTest.kt b/src/test/kotlin/com/dobby/backend/application/service/OauthServiceTest.kt index 942db32..2aabab9 100644 --- a/src/test/kotlin/com/dobby/backend/application/service/OauthServiceTest.kt +++ b/src/test/kotlin/com/dobby/backend/application/service/OauthServiceTest.kt @@ -1,8 +1,9 @@ import com.dobby.backend.application.service.OauthService import com.dobby.backend.application.usecase.FetchGoogleUserInfoUseCase +import com.dobby.backend.application.usecase.FetchNaverUserInfoUseCase import com.dobby.backend.infrastructure.database.entity.enum.ProviderType import com.dobby.backend.infrastructure.database.entity.enum.RoleType -import com.dobby.backend.presentation.api.dto.request.OauthLoginRequest +import com.dobby.backend.presentation.api.dto.request.auth.GoogleOauthLoginRequest import com.dobby.backend.presentation.api.dto.response.MemberResponse import com.dobby.backend.presentation.api.dto.response.auth.OauthLoginResponse import io.kotest.core.spec.style.BehaviorSpec @@ -14,10 +15,12 @@ import org.springframework.test.context.ActiveProfiles @ActiveProfiles("test") class OauthServiceTest : BehaviorSpec({ val fetchGoogleUserInfoUseCase = mockk() - val oauthService = OauthService(fetchGoogleUserInfoUseCase) + val fetchNaverUserInfoUseCase = mockk() + + val oauthService = OauthService(fetchGoogleUserInfoUseCase, fetchNaverUserInfoUseCase) given("Google OAuth 요청이 들어왔을 때") { - val oauthLoginRequest = OauthLoginRequest(authorizationCode = "valid-auth-code") + val oauthLoginRequest = GoogleOauthLoginRequest(authorizationCode = "valid-auth-code") val expectedResponse = OauthLoginResponse( isRegistered = true, accessToken = "mock-access-token", diff --git a/src/test/kotlin/com/dobby/backend/application/usecase/FetchGoogleUserInfoTest.kt b/src/test/kotlin/com/dobby/backend/application/usecase/FetchGoogleUserInfoTest.kt index 7558dc3..7aa36ad 100644 --- a/src/test/kotlin/com/dobby/backend/application/usecase/FetchGoogleUserInfoTest.kt +++ b/src/test/kotlin/com/dobby/backend/application/usecase/FetchGoogleUserInfoTest.kt @@ -5,11 +5,11 @@ import com.dobby.backend.infrastructure.database.entity.enum.MemberStatus import com.dobby.backend.infrastructure.database.entity.enum.ProviderType import com.dobby.backend.infrastructure.database.entity.enum.RoleType import com.dobby.backend.infrastructure.database.repository.MemberRepository -import com.dobby.backend.infrastructure.feign.GoogleAuthFeignClient -import com.dobby.backend.infrastructure.feign.GoogleUserInfoFeginClient +import com.dobby.backend.infrastructure.feign.google.GoogleAuthFeignClient +import com.dobby.backend.infrastructure.feign.google.GoogleUserInfoFeginClient import com.dobby.backend.infrastructure.token.JwtTokenProvider -import com.dobby.backend.presentation.api.dto.request.OauthLoginRequest -import com.dobby.backend.presentation.api.dto.response.auth.google.GoogleTokenResponse +import com.dobby.backend.presentation.api.dto.request.auth.GoogleOauthLoginRequest +import com.dobby.backend.presentation.api.dto.response.auth.GoogleTokenResponse import io.kotest.core.spec.style.BehaviorSpec import io.kotest.matchers.shouldBe import io.mockk.every @@ -34,7 +34,7 @@ class FetchGoogleUserInfoUseCaseTest : BehaviorSpec({ ) given("Google OAuth 요청이 들어왔을 때") { - val oauthLoginRequest = OauthLoginRequest(authorizationCode = "valid-auth-code") + val oauthLoginRequest = GoogleOauthLoginRequest(authorizationCode = "valid-auth-code") val mockMember = MemberEntity( id = 1L, oauthEmail = "test@example.com", diff --git a/src/test/kotlin/com/dobby/backend/application/usecase/FetchNaverUserInfoTest.kt b/src/test/kotlin/com/dobby/backend/application/usecase/FetchNaverUserInfoTest.kt new file mode 100644 index 0000000..a14507f --- /dev/null +++ b/src/test/kotlin/com/dobby/backend/application/usecase/FetchNaverUserInfoTest.kt @@ -0,0 +1,74 @@ +import com.dobby.backend.application.usecase.FetchNaverUserInfoUseCase +import com.dobby.backend.infrastructure.config.properties.NaverAuthProperties +import com.dobby.backend.infrastructure.database.entity.MemberEntity +import com.dobby.backend.infrastructure.database.entity.enum.MemberStatus +import com.dobby.backend.infrastructure.database.entity.enum.ProviderType +import com.dobby.backend.infrastructure.database.entity.enum.RoleType +import com.dobby.backend.infrastructure.database.repository.MemberRepository +import com.dobby.backend.infrastructure.feign.naver.NaverAuthFeignClient +import com.dobby.backend.infrastructure.feign.naver.NaverUserInfoFeignClient +import com.dobby.backend.infrastructure.token.JwtTokenProvider +import com.dobby.backend.presentation.api.dto.request.auth.NaverOauthLoginRequest +import com.dobby.backend.presentation.api.dto.response.auth.OauthLoginResponse +import com.dobby.backend.presentation.api.dto.response.auth.NaverTokenResponse +import io.kotest.core.spec.style.BehaviorSpec +import io.kotest.matchers.shouldBe +import io.mockk.every +import io.mockk.mockk +import org.springframework.test.context.ActiveProfiles +import java.time.LocalDate + +@ActiveProfiles("test") +class FetchNaverUserInfoUseCaseTest : BehaviorSpec({ + val naverAuthFeignClient = mockk() + val naverUserInfoFeginClient = mockk() + val jwtTokenProvider = mockk() + val naverAuthProperties = mockk() + val memberRepository = mockk() + + val fetchNaverUserInfoUseCase = FetchNaverUserInfoUseCase( + naverAuthFeignClient, + naverUserInfoFeginClient, + jwtTokenProvider, + naverAuthProperties, + memberRepository + ) + + given("Naver OAuth 요청이 들어왔을 때") { + val oauthLoginRequest = NaverOauthLoginRequest(authorizationCode = "valid-auth-code", state = "valid-state") + val mockMember = MemberEntity( + id = 1L, + oauthEmail = "test@example.com", + name = "Test User", + status = MemberStatus.ACTIVE, + role = RoleType.PARTICIPANT, + birthDate = LocalDate.of(2002, 11, 21), + contactEmail = "contact@example.com", + provider = ProviderType.NAVER + ) + + every { naverAuthProperties.clientId } returns "mock-client-id" + every { naverAuthProperties.clientSecret } returns "mock-client-secret" + every { naverAuthProperties.redirectUri } returns "http://localhost/callback" + every { naverAuthFeignClient.getAccessToken(any()) } returns NaverTokenResponse("mock-access-token") + every { naverUserInfoFeginClient.getUserInfo("Bearer mock-access-token") } returns mockk { + every { email } returns "test@example.com" + every { name } returns "Test User" + } + every { memberRepository.findByOauthEmailAndStatus("test@example.com", MemberStatus.ACTIVE) } returns mockMember + every { jwtTokenProvider.generateAccessToken(any()) } returns "mock-jwt-access-token" + every { jwtTokenProvider.generateRefreshToken(any()) } returns "mock-jwt-refresh-token" + + `when`("정상적으로 모든 데이터가 주어지면") { + val result: OauthLoginResponse = fetchNaverUserInfoUseCase.execute(oauthLoginRequest) + + then("유저 정보를 포함한 OauthLoginResponse를 반환해야 한다") { + result.isRegistered shouldBe true + result.accessToken shouldBe "mock-jwt-access-token" + result.refreshToken shouldBe "mock-jwt-refresh-token" + result.memberInfo.oauthEmail shouldBe "test@example.com" + result.memberInfo.name shouldBe "Test User" + } + } + } +}) diff --git a/src/test/kotlin/com/dobby/backend/application/usecase/ParticipantSignupUseCaseTest.kt b/src/test/kotlin/com/dobby/backend/application/usecase/ParticipantSignupUseCaseTest.kt index c25997e..1a34ec5 100644 --- a/src/test/kotlin/com/dobby/backend/application/usecase/ParticipantSignupUseCaseTest.kt +++ b/src/test/kotlin/com/dobby/backend/application/usecase/ParticipantSignupUseCaseTest.kt @@ -4,12 +4,13 @@ import com.dobby.backend.application.mapper.SignupMapper import com.dobby.backend.infrastructure.database.entity.ParticipantEntity import com.dobby.backend.infrastructure.database.entity.enum.GenderType import com.dobby.backend.infrastructure.database.entity.enum.MatchType +import com.dobby.backend.infrastructure.database.entity.enum.ProviderType import com.dobby.backend.infrastructure.database.entity.enum.areaInfo.Area import com.dobby.backend.infrastructure.database.entity.enum.areaInfo.Region import com.dobby.backend.infrastructure.database.repository.ParticipantRepository import com.dobby.backend.infrastructure.token.JwtTokenProvider -import com.dobby.backend.presentation.api.dto.request.ParticipantSignupRequest -import com.dobby.backend.presentation.api.dto.request.AddressInfo as DtoAddressInfo +import com.dobby.backend.presentation.api.dto.request.signup.ParticipantSignupRequest +import com.dobby.backend.presentation.api.dto.request.signup.AddressInfo as DtoAddressInfo import io.kotest.core.spec.style.BehaviorSpec import io.kotest.matchers.shouldBe import io.mockk.every @@ -26,7 +27,7 @@ class ParticipantSignupUseCaseTest : BehaviorSpec({ val request = ParticipantSignupRequest( oauthEmail = "test@example.com", - provider = com.dobby.backend.infrastructure.database.entity.enum.ProviderType.GOOGLE, + provider = ProviderType.GOOGLE, contactEmail = "contact@example.com", name = "Test User", birthDate = LocalDate.of(2002, 11, 21),