From ffa620d90d4d92ce5560ed4f326677f18dffdbfc Mon Sep 17 00:00:00 2001 From: sangminnim Date: Wed, 1 Nov 2023 16:56:09 +0900 Subject: [PATCH 1/9] =?UTF-8?q?test:=20ObjectMapper=20Autowired=EB=A1=9C?= =?UTF-8?q?=20=EC=A3=BC=EC=9E=85=20=EB=B0=8F=20Json=20=EA=B0=81=20?= =?UTF-8?q?=EC=9A=94=EC=86=8C=20=EA=B2=80=EC=A6=9D=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EC=A0=84=EC=B2=B4=EA=B2=80=EC=A6=9D=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/controller/AuthControllerTest.java | 5 ++-- .../common/config/ControllerTestConfig.java | 4 ++- .../user/controller/UserControllerTest.java | 26 +++++-------------- 3 files changed, 11 insertions(+), 24 deletions(-) diff --git a/src/test/java/coffeemeet/server/auth/controller/AuthControllerTest.java b/src/test/java/coffeemeet/server/auth/controller/AuthControllerTest.java index 345feb1a..9620969e 100644 --- a/src/test/java/coffeemeet/server/auth/controller/AuthControllerTest.java +++ b/src/test/java/coffeemeet/server/auth/controller/AuthControllerTest.java @@ -14,7 +14,7 @@ import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint; import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import coffeemeet.server.auth.domain.AuthTokens; @@ -67,8 +67,7 @@ void renewTest() throws Exception { ) ) .andExpect(status().isOk()) - .andExpect(jsonPath("$.accessToken").value(authTokens.accessToken())) - .andExpect(jsonPath("$.refreshToken").value(authTokens.refreshToken())); + .andExpect(content().string(objectMapper.writeValueAsString(authTokens))); } @DisplayName("사용자는 로그아웃 할 수 있다.") diff --git a/src/test/java/coffeemeet/server/common/config/ControllerTestConfig.java b/src/test/java/coffeemeet/server/common/config/ControllerTestConfig.java index 59dc84ad..56ea70d9 100644 --- a/src/test/java/coffeemeet/server/common/config/ControllerTestConfig.java +++ b/src/test/java/coffeemeet/server/common/config/ControllerTestConfig.java @@ -8,6 +8,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.restdocs.RestDocumentationContextProvider; import org.springframework.restdocs.RestDocumentationExtension; @@ -21,7 +22,8 @@ public abstract class ControllerTestConfig { protected static final String TOKEN = "Bearer header.payload.signature"; - protected ObjectMapper objectMapper = new ObjectMapper(); + @Autowired + protected ObjectMapper objectMapper; protected MockMvc mockMvc; diff --git a/src/test/java/coffeemeet/server/user/controller/UserControllerTest.java b/src/test/java/coffeemeet/server/user/controller/UserControllerTest.java index d61efe57..61263245 100644 --- a/src/test/java/coffeemeet/server/user/controller/UserControllerTest.java +++ b/src/test/java/coffeemeet/server/user/controller/UserControllerTest.java @@ -24,7 +24,7 @@ import static org.springframework.restdocs.request.RequestDocumentation.pathParameters; import static org.springframework.restdocs.request.RequestDocumentation.queryParameters; import static org.springframework.restdocs.request.RequestDocumentation.requestParts; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import coffeemeet.server.auth.domain.AuthTokens; @@ -88,8 +88,8 @@ void signupTest() throws Exception { ) )) .andExpect(status().isOk()) - .andExpect(jsonPath("$.accessToken").value("accessToken")) - .andExpect(jsonPath("$.refreshToken").value("refreshToken")); + .andExpect(content().string(objectMapper.writeValueAsString(authTokens))); + } @Test @@ -121,8 +121,7 @@ void loginTest() throws Exception { ) )) .andExpect(status().isOk()) - .andExpect(jsonPath("$.accessToken").value("accessToken")) - .andExpect(jsonPath("$.refreshToken").value("refreshToken")); + .andExpect(content().string(objectMapper.writeValueAsString(authTokens))); } @Test @@ -155,10 +154,7 @@ void findUserProfileTest() throws Exception { ) ) .andExpect(status().isOk()) - .andExpect(jsonPath("$.nickname").value(response.nickname())) - .andExpect(jsonPath("$.profileImageUrl").value(response.profileImageUrl())) - .andExpect(jsonPath("$.department").value(String.valueOf(response.department()))) - .andExpect(jsonPath("$.interests[0]").value(response.interests().get(0).name())); + .andExpect(content().string(objectMapper.writeValueAsString(response))); } @Test @@ -199,17 +195,7 @@ void findMyProfileTest() throws Exception { ) ) ) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.name").value(response.name())) - .andExpect(jsonPath("$.nickname").value(response.nickname())) - .andExpect(jsonPath("$.email").value(response.email())) - .andExpect(jsonPath("$.profileImageUrl").value(response.profileImageUrl())) - .andExpect(jsonPath("$.birthYear").value(response.birthYear())) - .andExpect(jsonPath("$.birthDay").value(response.birthDay())) - .andExpect(jsonPath("$.reportedCount").value(response.reportedCount())) - .andExpect(jsonPath("$.sanctionPeriod").value(String.valueOf(response.sanctionPeriod()))) - .andExpect(jsonPath("$.department").value(String.valueOf(response.department()))) - .andExpect(jsonPath("$.interests[0]").value(response.interests().get(0).name())); + .andExpect(content().string(objectMapper.writeValueAsString(response))); } @Test From 50dca8fbc966d1d3dd67e7691062f875edd8e5b5 Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Wed, 1 Nov 2023 17:20:55 +0900 Subject: [PATCH 2/9] refactor: update yml --- src/main/resources/application.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index e029a289..aa30d4d8 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -20,8 +20,8 @@ spring: password: ${REDIS_PASSWORD} mail: - host: ${MAIL_HOST} - port: ${MAIL_PORT} + host: smtp.gmail.com + port: 587 username: ${MAIL_USERNAME} password: ${MAIL_PASSWORD} properties: From b3276af2f80a9224000c5397d895c5c4f23a55ec Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Wed, 1 Nov 2023 17:48:31 +0900 Subject: [PATCH 3/9] docs: update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 18803d0a..ef1937f9 100644 --- a/README.md +++ b/README.md @@ -1 +1,2 @@ # backend +배포 v 1.1 From b52f3e3c6ec7f168d3ab8d6199bba67933e0f116 Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Wed, 1 Nov 2023 18:02:35 +0900 Subject: [PATCH 4/9] docs: update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ef1937f9..e8552b88 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ # backend -배포 v 1.1 +배포 v 1.1 test From be086d37e75f38ca4e7afa13938e55258d18619a Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Thu, 2 Nov 2023 14:19:35 +0900 Subject: [PATCH 5/9] refactor: update yml --- src/main/resources/application.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index aa30d4d8..e029a289 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -20,8 +20,8 @@ spring: password: ${REDIS_PASSWORD} mail: - host: smtp.gmail.com - port: 587 + host: ${MAIL_HOST} + port: ${MAIL_PORT} username: ${MAIL_USERNAME} password: ${MAIL_PASSWORD} properties: From 5ee9b78722101b2efa10311c18b9fa85a5e194cc Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Thu, 2 Nov 2023 14:28:53 +0900 Subject: [PATCH 6/9] refactor: update Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 3e9a838e..cb76c4c1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM openjdk:17-jdk-alpine +FROM openjdk:17-jdk ARG JAR_FILE=build/libs/*.jar COPY ${JAR_FILE} app.jar ENTRYPOINT ["java", "-jar", "app.jar"] From 8975f3f0c8d33bd31da6227e3ffe12d5747e1ff8 Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Thu, 2 Nov 2023 14:36:34 +0900 Subject: [PATCH 7/9] =?UTF-8?q?feat:=20WebConfig=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/common/config/WebConfig.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/main/java/coffeemeet/server/common/config/WebConfig.java diff --git a/src/main/java/coffeemeet/server/common/config/WebConfig.java b/src/main/java/coffeemeet/server/common/config/WebConfig.java new file mode 100644 index 00000000..1316b1d4 --- /dev/null +++ b/src/main/java/coffeemeet/server/common/config/WebConfig.java @@ -0,0 +1,18 @@ +package coffeemeet.server.common.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class WebConfig implements WebMvcConfigurer { + + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**") + .allowedOrigins("*") + .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") + .allowedHeaders("*"); + } + +} From cebce6a17c63838d1c6c4983714c69e4f6db1bf6 Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Thu, 2 Nov 2023 14:48:03 +0900 Subject: [PATCH 8/9] refactor: update gradle --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 2a9b8a27..cc57f6dc 100644 --- a/build.gradle +++ b/build.gradle @@ -87,7 +87,7 @@ swaggerSources { openapi3 { servers = [ { url = "http://localhost:8080" }, - { url = "http://13.209.253.204:8080" } + { url = "http://13.125.194.230/:8080" } ] title = "API 문서" description = "RestDocsWithSwagger Docs" From 212bb16a435dd9c93aef17a90c80d44f5b7479de Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Thu, 2 Nov 2023 14:57:31 +0900 Subject: [PATCH 9/9] refactor: update gradle --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index cc57f6dc..5cf6efae 100644 --- a/build.gradle +++ b/build.gradle @@ -87,7 +87,7 @@ swaggerSources { openapi3 { servers = [ { url = "http://localhost:8080" }, - { url = "http://13.125.194.230/:8080" } + { url = "http://13.125.194.230:8080" } ] title = "API 문서" description = "RestDocsWithSwagger Docs"