From 530b39bffb9194e6280b22a2583294108160516e Mon Sep 17 00:00:00 2001 From: letskuku Date: Mon, 29 Jul 2024 00:35:03 +0900 Subject: [PATCH 1/5] =?UTF-8?q?[feat]=20=EC=A7=80=EC=9B=90=EC=84=9C=20?= =?UTF-8?q?=EB=AA=A9=EB=A1=9D=20=EB=B3=B4=EA=B8=B0=20API=20required=20fals?= =?UTF-8?q?e=EC=9D=B8=20parameter=EB=93=A4=EC=97=90=20=EB=8C=80=ED=95=B4?= =?UTF-8?q?=20default=20value=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/domain/application/ApplicationController.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/ceos/backend/domain/application/ApplicationController.java b/src/main/java/ceos/backend/domain/application/ApplicationController.java index fa11c75..d2a2b7d 100644 --- a/src/main/java/ceos/backend/domain/application/ApplicationController.java +++ b/src/main/java/ceos/backend/domain/application/ApplicationController.java @@ -40,10 +40,10 @@ public class ApplicationController { @Operation(summary = "지원자 목록 보기") @GetMapping public GetApplications getApplications( - @RequestParam(value = "part", required = false) Part part, - @RequestParam(value = "docPass", required = false) Pass docPass, - @RequestParam(value = "finalPass", required = false) Pass finalPass, - @RequestParam(value = "applicantName", required = false) String applicantName, + @RequestParam(value = "part", required = false, defaultValue = "") Part part, + @RequestParam(value = "docPass", required = false, defaultValue = "") Pass docPass, + @RequestParam(value = "finalPass", required = false, defaultValue = "") Pass finalPass, + @RequestParam(value = "applicantName", required = false, defaultValue = "") String applicantName, @RequestParam("pageNum") int pageNum, @RequestParam("limit") int limit) { log.info("지원자 목록 보기"); From 9380e57db3fd404cea999775c11eb4eb54a993c7 Mon Sep 17 00:00:00 2001 From: letskuku Date: Mon, 29 Jul 2024 00:35:15 +0900 Subject: [PATCH 2/5] =?UTF-8?q?[test]=20=EC=A7=80=EC=9B=90=EC=84=9C=20?= =?UTF-8?q?=EB=AA=A9=EB=A1=9D=20=EB=B3=B4=EA=B8=B0=20API=20required=20fals?= =?UTF-8?q?e=EC=9D=B8=20parameter=EB=93=A4=EC=97=90=20=EB=8C=80=ED=95=9C?= =?UTF-8?q?=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=BD=94=EB=93=9C=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApplicationControllerTest.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/test/java/ceos/backend/domain/application/ApplicationControllerTest.java b/src/test/java/ceos/backend/domain/application/ApplicationControllerTest.java index 31ca80f..89cb955 100644 --- a/src/test/java/ceos/backend/domain/application/ApplicationControllerTest.java +++ b/src/test/java/ceos/backend/domain/application/ApplicationControllerTest.java @@ -6,6 +6,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.security.authentication.TestingAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import org.springframework.test.web.servlet.result.MockMvcResultMatchers; @@ -22,4 +25,26 @@ void getApplicationExcelCreationTime() throws Exception { mockMvc.perform(MockMvcRequestBuilders.get("/applications/file/creationtime")) .andExpect(MockMvcResultMatchers.status().is(401)); } + + @DisplayName("지원서 목록 보기 API - 필수 아닌 파라미터들 길이 0인 문자열로 처리") + @Test + void getApplicationsWithZeroStrings() throws Exception { + Authentication authentication = new TestingAuthenticationToken(null, null, "ROLE_ADMIN"); + + mockMvc.perform(MockMvcRequestBuilders + .get("/applications?part=&docPass=&finalPass=&applicantName=&pageNum=0&limit=7") + .with(SecurityMockMvcRequestPostProcessors.authentication(authentication))) + .andExpect(MockMvcResultMatchers.status().isOk()); + } + + @DisplayName("지원서 목록 보기 API - 필수 아닌 파라미터들 제외") + @Test + void getApplicationsWithoutRequiredFalse() throws Exception { + Authentication authentication = new TestingAuthenticationToken(null, null, "ROLE_ADMIN"); + + mockMvc.perform(MockMvcRequestBuilders + .get("/applications?pageNum=0&limit=7") + .with(SecurityMockMvcRequestPostProcessors.authentication(authentication))) + .andExpect(MockMvcResultMatchers.status().isOk()); + } } From a1b085f0a74e6d23187dd2fd8b18dfe9572fb925 Mon Sep 17 00:00:00 2001 From: letskuku Date: Mon, 29 Jul 2024 00:38:45 +0900 Subject: [PATCH 3/5] =?UTF-8?q?[feat]=20=EC=A7=80=EC=9B=90=EC=84=9C=20?= =?UTF-8?q?=EB=AA=A9=EB=A1=9D=20=EB=B3=B4=EA=B8=B0=20API=20enum=20?= =?UTF-8?q?=ED=83=80=EC=9E=85=EC=9D=B8=20parameter=EB=93=A4=EC=97=90=20?= =?UTF-8?q?=EB=8C=80=ED=95=B4=20allowable=20values=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/domain/application/ApplicationController.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/ceos/backend/domain/application/ApplicationController.java b/src/main/java/ceos/backend/domain/application/ApplicationController.java index d2a2b7d..f7a0f9c 100644 --- a/src/main/java/ceos/backend/domain/application/ApplicationController.java +++ b/src/main/java/ceos/backend/domain/application/ApplicationController.java @@ -17,6 +17,8 @@ import ceos.backend.domain.application.service.ApplicationService; import ceos.backend.global.common.entity.Part; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import java.nio.file.Path; @@ -40,8 +42,11 @@ public class ApplicationController { @Operation(summary = "지원자 목록 보기") @GetMapping public GetApplications getApplications( + @Parameter(schema = @Schema(allowableValues = {"PRODUCT", "DESIGN", "FRONTEND", "BACKEND"})) @RequestParam(value = "part", required = false, defaultValue = "") Part part, + @Parameter(schema = @Schema(allowableValues = {"PASS", "FAIL"})) @RequestParam(value = "docPass", required = false, defaultValue = "") Pass docPass, + @Parameter(schema = @Schema(allowableValues = {"PASS", "FAIL"})) @RequestParam(value = "finalPass", required = false, defaultValue = "") Pass finalPass, @RequestParam(value = "applicantName", required = false, defaultValue = "") String applicantName, @RequestParam("pageNum") int pageNum, From 41234fe4c6e16c72af28e3f58531c6f07a1ada39 Mon Sep 17 00:00:00 2001 From: letskuku Date: Mon, 29 Jul 2024 00:39:07 +0900 Subject: [PATCH 4/5] =?UTF-8?q?[test]=20=EC=A7=80=EC=9B=90=EC=84=9C=20?= =?UTF-8?q?=EB=AA=A9=EB=A1=9D=20=EB=B3=B4=EA=B8=B0=20API=20enum=20?= =?UTF-8?q?=ED=83=80=EC=9E=85=EC=9D=B8=20parameter=EB=93=A4=EC=97=90=20?= =?UTF-8?q?=EB=8C=80=ED=95=B4=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApplicationControllerTest.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/test/java/ceos/backend/domain/application/ApplicationControllerTest.java b/src/test/java/ceos/backend/domain/application/ApplicationControllerTest.java index 89cb955..5550209 100644 --- a/src/test/java/ceos/backend/domain/application/ApplicationControllerTest.java +++ b/src/test/java/ceos/backend/domain/application/ApplicationControllerTest.java @@ -47,4 +47,26 @@ void getApplicationsWithoutRequiredFalse() throws Exception { .with(SecurityMockMvcRequestPostProcessors.authentication(authentication))) .andExpect(MockMvcResultMatchers.status().isOk()); } + + @DisplayName("지원서 목록 보기 API - enum 타입 영어로 처리") + @Test + void successGetApplications() throws Exception { + Authentication authentication = new TestingAuthenticationToken(null, null, "ROLE_ADMIN"); + + mockMvc.perform(MockMvcRequestBuilders + .get("/applications?part=PRODUCT&docPass=PASS&finalPass=FAIL&applicantName=&pageNum=0&limit=7") + .with(SecurityMockMvcRequestPostProcessors.authentication(authentication))) + .andExpect(MockMvcResultMatchers.status().isOk()); + } + + @DisplayName("지원서 목록 보기 API - enum 타입 한글로 처리 시 예외 발생") + @Test + void failGetApplications() throws Exception { + Authentication authentication = new TestingAuthenticationToken(null, null, "ROLE_ADMIN"); + + mockMvc.perform(MockMvcRequestBuilders + .get("/applications?part=기획&docPass=합격&finalPass=불합격&applicantName=&pageNum=0&limit=7") + .with(SecurityMockMvcRequestPostProcessors.authentication(authentication))) + .andExpect(MockMvcResultMatchers.status().is(400)); + } } From c468d53a7f92884659f578309006540a7f967151 Mon Sep 17 00:00:00 2001 From: letskuku Date: Mon, 29 Jul 2024 00:40:20 +0900 Subject: [PATCH 5/5] =?UTF-8?q?[fix]=20=EC=A7=80=EC=9B=90=EC=84=9C=20?= =?UTF-8?q?=EC=97=91=EC=85=80=20=ED=8C=8C=EC=9D=BC=20=EC=83=9D=EC=84=B1=20?= =?UTF-8?q?=EC=8B=9C=EA=B0=81=20API=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20status?= =?UTF-8?q?=20code=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/domain/application/ApplicationControllerTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/ceos/backend/domain/application/ApplicationControllerTest.java b/src/test/java/ceos/backend/domain/application/ApplicationControllerTest.java index 5550209..e135090 100644 --- a/src/test/java/ceos/backend/domain/application/ApplicationControllerTest.java +++ b/src/test/java/ceos/backend/domain/application/ApplicationControllerTest.java @@ -23,7 +23,7 @@ public class ApplicationControllerTest { @Test void getApplicationExcelCreationTime() throws Exception { mockMvc.perform(MockMvcRequestBuilders.get("/applications/file/creationtime")) - .andExpect(MockMvcResultMatchers.status().is(401)); + .andExpect(MockMvcResultMatchers.status().is(403)); } @DisplayName("지원서 목록 보기 API - 필수 아닌 파라미터들 길이 0인 문자열로 처리")