Skip to content

Commit

Permalink
feat: 휴대폰 번호로 이메일 찾기 API 쿼리 파람으로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
nuyh99 committed Nov 25, 2023
1 parent 4439664 commit 06ce665
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
7 changes: 3 additions & 4 deletions src/main/java/com/example/busan/auth/AuthController.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.example.busan.auth.dto.AuthenticatePhoneRequest;
import com.example.busan.auth.dto.Authentication;
import com.example.busan.auth.dto.FindEmailRequest;
import com.example.busan.auth.dto.FindEmailResponse;
import com.example.busan.auth.dto.LoginRequest;
import com.example.busan.auth.service.AuthService;
Expand Down Expand Up @@ -56,9 +55,9 @@ public ResponseEntity<Void> authenticate(@RequestParam("code") String code) {
}

@GetMapping("/email")
public ResponseEntity<FindEmailResponse> findEmailByPhone(@RequestBody final FindEmailRequest request) {
phoneAuthenticator.validateAuthenticated(request.phone());
final FindEmailResponse response = authService.findEmailByPhone(request.phone());
public ResponseEntity<FindEmailResponse> findEmailByPhone(@RequestParam("phone") final String phone) {
phoneAuthenticator.validateAuthenticated(phone);
final FindEmailResponse response = authService.findEmailByPhone(phone);
return ResponseEntity.ok(response);
}
}
7 changes: 2 additions & 5 deletions src/test/java/com/example/busan/auth/AuthControllerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.example.busan.ApiTest;
import com.example.busan.auth.dto.AuthenticatePhoneRequest;
import com.example.busan.auth.dto.Authentication;
import com.example.busan.auth.dto.FindEmailRequest;
import com.example.busan.auth.dto.FindEmailResponse;
import com.example.busan.auth.dto.LoginRequest;
import com.example.busan.auth.service.AuthService;
Expand Down Expand Up @@ -134,16 +133,14 @@ void findEmailByPhone() throws Exception {
//given
given(authService.findEmailByPhone(any()))
.willReturn(new FindEmailResponse("[email protected]"));
final String request = objectMapper.writeValueAsString(new FindEmailRequest("01012345678"));

//when
final MockHttpServletResponse response = mockMvc.perform(
get("/auth/email")
.content(request)
.contentType(MediaType.APPLICATION_JSON))
.queryParam("phone", "01012341234"))
.andDo(print())
.andDo(document("휴대폰 번호로 이메일 찾기",
requestFields(fieldWithPath("phone").description("인증 완료된 휴대폰 번호")),
queryParameters(parameterWithName("phone").description("인증 완료된 휴대폰 번호")),
responseFields(fieldWithPath("email").description("해당 번호의 이메일"))))
.andReturn()
.getResponse();
Expand Down

0 comments on commit 06ce665

Please sign in to comment.