From 6e18c8334d6dbc7df74c6664f32aa2b26c94384a Mon Sep 17 00:00:00 2001 From: elyudwo Date: Wed, 28 Feb 2024 17:04:28 +0900 Subject: [PATCH] =?UTF-8?q?[Refactor]=20:=20=EC=9D=B4=EB=A9=94=EC=9D=BC=20?= =?UTF-8?q?=EA=B4=80=EB=A0=A8=20=EA=B8=B0=EB=8A=A5=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit INU 이메일이 아닌 다른 사이트의 이메일도 허용 --- .../email/dto/request/MailSendRequest.java | 4 +- .../request/MailValidDuplicationRequest.java | 4 +- .../email/dto/request/MailValidRequest.java | 4 +- .../email/dto/request/QuestionRequest.java | 1 + .../user/dto/request/SignInRequest.java | 3 +- .../user/dto/request/SignUpRequest.java | 6 +-- .../user/controller/UserControllerTest.java | 44 +++++++++---------- 7 files changed, 36 insertions(+), 30 deletions(-) diff --git a/src/main/java/kr/co/studyhubinu/studyhubserver/email/dto/request/MailSendRequest.java b/src/main/java/kr/co/studyhubinu/studyhubserver/email/dto/request/MailSendRequest.java index 81797e44..1340ada6 100644 --- a/src/main/java/kr/co/studyhubinu/studyhubserver/email/dto/request/MailSendRequest.java +++ b/src/main/java/kr/co/studyhubinu/studyhubserver/email/dto/request/MailSendRequest.java @@ -3,6 +3,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import kr.co.studyhubinu.studyhubserver.email.dto.data.MailInfo; import kr.co.studyhubinu.studyhubserver.email.validate.InuEmail; +import kr.co.studyhubinu.studyhubserver.email.validate.NormalEmail; import lombok.Getter; import javax.validation.constraints.NotBlank; @@ -12,7 +13,8 @@ public class MailSendRequest { @Schema(description = "이메일 주소", example = "kdw990202@inu.ac.kr") @NotBlank - @InuEmail(message = "이메일 형식에 맞지 않습니다. (인천대학교 이메일 주소만 가능)") + @NormalEmail +// @InuEmail(message = "이메일 형식에 맞지 않습니다. (인천대학교 이메일 주소만 가능)") private String email; public MailInfo toService() { diff --git a/src/main/java/kr/co/studyhubinu/studyhubserver/email/dto/request/MailValidDuplicationRequest.java b/src/main/java/kr/co/studyhubinu/studyhubserver/email/dto/request/MailValidDuplicationRequest.java index 0a8b285a..d9244571 100644 --- a/src/main/java/kr/co/studyhubinu/studyhubserver/email/dto/request/MailValidDuplicationRequest.java +++ b/src/main/java/kr/co/studyhubinu/studyhubserver/email/dto/request/MailValidDuplicationRequest.java @@ -3,6 +3,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import kr.co.studyhubinu.studyhubserver.email.dto.data.ValidDuplicationInfo; import kr.co.studyhubinu.studyhubserver.email.validate.InuEmail; +import kr.co.studyhubinu.studyhubserver.email.validate.NormalEmail; import lombok.Getter; import javax.validation.constraints.NotBlank; @@ -12,7 +13,8 @@ public class MailValidDuplicationRequest { @Schema(description = "이메일 주소", example = "kdw990202@inu.ac.kr") @NotBlank - @InuEmail(message = "이메일 형식에 맞지 않습니다. (인천대학교 이메일 주소만 가능)") + @NormalEmail +// @InuEmail(message = "이메일 형식에 맞지 않습니다. (인천대학교 이메일 주소만 가능)") private String email; public ValidDuplicationInfo toService() { diff --git a/src/main/java/kr/co/studyhubinu/studyhubserver/email/dto/request/MailValidRequest.java b/src/main/java/kr/co/studyhubinu/studyhubserver/email/dto/request/MailValidRequest.java index e110b240..15e28749 100644 --- a/src/main/java/kr/co/studyhubinu/studyhubserver/email/dto/request/MailValidRequest.java +++ b/src/main/java/kr/co/studyhubinu/studyhubserver/email/dto/request/MailValidRequest.java @@ -3,6 +3,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import kr.co.studyhubinu.studyhubserver.email.dto.data.ValidMailInfo; import kr.co.studyhubinu.studyhubserver.email.validate.InuEmail; +import kr.co.studyhubinu.studyhubserver.email.validate.NormalEmail; import lombok.Getter; import javax.validation.constraints.NotBlank; @@ -12,7 +13,8 @@ public class MailValidRequest { @Schema(description = "이메일 주소", example = "kdw990202@inu.ac.kr") @NotBlank - @InuEmail(message = "이메일 형식에 맞지 않습니다. (인천대학교 이메일 주소만 가능)") + @NormalEmail +// @InuEmail(message = "이메일 형식에 맞지 않습니다. (인천대학교 이메일 주소만 가능)") private String email; private String authCode; diff --git a/src/main/java/kr/co/studyhubinu/studyhubserver/email/dto/request/QuestionRequest.java b/src/main/java/kr/co/studyhubinu/studyhubserver/email/dto/request/QuestionRequest.java index 93daddf6..379e082a 100644 --- a/src/main/java/kr/co/studyhubinu/studyhubserver/email/dto/request/QuestionRequest.java +++ b/src/main/java/kr/co/studyhubinu/studyhubserver/email/dto/request/QuestionRequest.java @@ -12,6 +12,7 @@ public class QuestionRequest { @Schema(description = "제목", example = "글 작성이 안되요") @NotBlank(message = "제목값은 필수 입니다") private String title; + @Schema(description = "내용", example = "스터디 글 작성하려 했는데 어플이 꺼집니다") @NotBlank(message = "내용값은 필수 입니다") private String content; diff --git a/src/main/java/kr/co/studyhubinu/studyhubserver/user/dto/request/SignInRequest.java b/src/main/java/kr/co/studyhubinu/studyhubserver/user/dto/request/SignInRequest.java index 94a6780c..05d47967 100644 --- a/src/main/java/kr/co/studyhubinu/studyhubserver/user/dto/request/SignInRequest.java +++ b/src/main/java/kr/co/studyhubinu/studyhubserver/user/dto/request/SignInRequest.java @@ -2,6 +2,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import kr.co.studyhubinu.studyhubserver.email.validate.InuEmail; +import kr.co.studyhubinu.studyhubserver.email.validate.NormalEmail; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; @@ -14,7 +15,7 @@ public class SignInRequest { @Schema(description = "유저 이메일", example = "studyHub@inu.ac.kr") @NotBlank - @InuEmail(message = "이메일 형식에 맞지 않습니다. (인천대학교 이메일 주소만 가능)") + @NormalEmail private String email; @Schema(description = "유저 비밀번호", example = "asdasdasd!!") diff --git a/src/main/java/kr/co/studyhubinu/studyhubserver/user/dto/request/SignUpRequest.java b/src/main/java/kr/co/studyhubinu/studyhubserver/user/dto/request/SignUpRequest.java index bb355217..315cfec1 100644 --- a/src/main/java/kr/co/studyhubinu/studyhubserver/user/dto/request/SignUpRequest.java +++ b/src/main/java/kr/co/studyhubinu/studyhubserver/user/dto/request/SignUpRequest.java @@ -1,6 +1,7 @@ package kr.co.studyhubinu.studyhubserver.user.dto.request; import io.swagger.v3.oas.annotations.media.Schema; +import kr.co.studyhubinu.studyhubserver.email.validate.NormalEmail; import kr.co.studyhubinu.studyhubserver.user.dto.data.SignUpInfo; import kr.co.studyhubinu.studyhubserver.user.enums.GenderType; import kr.co.studyhubinu.studyhubserver.user.enums.MajorType; @@ -17,10 +18,7 @@ public class SignUpRequest { @Schema(description = "유저 이메일", example = "studyHub@inu.ac.kr") - @Pattern( - regexp = "^[A-Za-z0-9._%+-]+@inu\\.ac\\.kr$", - message = "이메일 형식에 맞지 않습니다. (인천대학교 이메일 주소만 가능)" - ) + @NormalEmail @NotBlank private String email; diff --git a/src/test/java/kr/co/studyhubinu/studyhubserver/user/controller/UserControllerTest.java b/src/test/java/kr/co/studyhubinu/studyhubserver/user/controller/UserControllerTest.java index ee26b444..faf5f85d 100644 --- a/src/test/java/kr/co/studyhubinu/studyhubserver/user/controller/UserControllerTest.java +++ b/src/test/java/kr/co/studyhubinu/studyhubserver/user/controller/UserControllerTest.java @@ -111,28 +111,28 @@ static Stream emailParameters() { assertTrue(responseBody.contains("비밀번호는 10자 이상이어야 하며, 하나 이상의 특수문자를 포함해야 합니다.")); } - @ParameterizedTest(name = "{0}") - @MethodSource("emailParameters") - void 잘못된_형식_이메일로_회원가입시_예외발생(String testName, String email) throws Exception { - // given - SignUpRequest signUpRequest = SignUpRequest.builder() - .email(email) - .nickname("포이리에") - .gender(GenderType.MALE) - .password("dwdwdwdwdwdw@") - .build(); - - // when - ResultActions resultActions = performPostRequest("/api/v1/users/signup", signUpRequest); - - MvcResult mvcResult = resultActions.andReturn(); - String responseBody = mvcResult.getResponse().getContentAsString(UTF_8); - - // then - resultActions.andExpect(status().is4xxClientError()) - .andDo(print()); - assertTrue(responseBody.contains("이메일 형식에 맞지 않습니다. (인천대학교 이메일 주소만 가능)")); - } +// @ParameterizedTest(name = "{0}") +// @MethodSource("emailParameters") +// void 잘못된_형식_이메일로_회원가입시_예외발생(String testName, String email) throws Exception { +// // given +// SignUpRequest signUpRequest = SignUpRequest.builder() +// .email(email) +// .nickname("포이리에") +// .gender(GenderType.MALE) +// .password("dwdwdwdwdwdw@") +// .build(); +// +// // when +// ResultActions resultActions = performPostRequest("/api/v1/users/signup", signUpRequest); +// +// MvcResult mvcResult = resultActions.andReturn(); +// String responseBody = mvcResult.getResponse().getContentAsString(UTF_8); +// +// // then +// resultActions.andExpect(status().is4xxClientError()) +// .andDo(print()); +// assertTrue(responseBody.contains("이메일 형식에 맞지 않습니다. (인천대학교 이메일 주소만 가능)")); +// } @Test void 로그인_성공시_토큰_반환() throws Exception {