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"] diff --git a/README.md b/README.md index 18803d0a..e8552b88 100644 --- a/README.md +++ b/README.md @@ -1 +1,2 @@ # backend +배포 v 1.1 test diff --git a/build.gradle b/build.gradle index 2a9b8a27..5cf6efae 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" 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("*"); + } + +} 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