From 2746c4569374c09e8a3f3293d27a986d08e9fd20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8C=E1=85=A5=E1=86=BC=E1=84=86=E1=85=B5=E1=86=AB?= =?UTF-8?q?=E1=84=89=E1=85=A5=E1=86=A8?= Date: Wed, 1 May 2019 14:50:19 +0900 Subject: [PATCH 01/21] =?UTF-8?q?feature=20:=20profile=EC=84=A4=EC=A0=95?= =?UTF-8?q?=20,=20logback=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../codesquad/configration/WebMvcConfig.java | 6 +- .../java/codesquad/domain/AccountType.java | 12 ++-- .../intercepter/AdminInterceptor.java | 2 +- ...{ManagerAccount.java => AdminAccount.java} | 4 +- ...AccountHandlerMethodArgumentResolver.java} | 6 +- .../web/ApiMenuCategoryController.java | 6 +- .../resources/application-local.properties | 6 ++ .../resources/application-prod.properties | 8 +++ src/main/resources/application.properties | 17 ++--- src/main/resources/import.sql | 2 +- src/main/resources/logback-local.xml | 12 ++++ src/main/resources/logback-prod.xml | 30 +++++++++ src/main/resources/static/css/main.css | 25 +++++++ src/main/resources/static/js/main.js | 67 +++++++++++++++++++ src/main/resources/templates/index.hbs | 3 +- .../web/ApiMenuCategoryControllerTest.java | 12 ++-- 16 files changed, 178 insertions(+), 40 deletions(-) rename src/main/java/codesquad/security/{ManagerAccount.java => AdminAccount.java} (72%) rename src/main/java/codesquad/security/{ManagerAccountHandlerMethodArgumentResolver.java => AdminAccountHandlerMethodArgumentResolver.java} (82%) create mode 100755 src/main/resources/application-local.properties create mode 100644 src/main/resources/application-prod.properties create mode 100644 src/main/resources/logback-local.xml create mode 100644 src/main/resources/logback-prod.xml create mode 100644 src/main/resources/static/js/main.js diff --git a/src/main/java/codesquad/configration/WebMvcConfig.java b/src/main/java/codesquad/configration/WebMvcConfig.java index 081e95c..b16c0f0 100644 --- a/src/main/java/codesquad/configration/WebMvcConfig.java +++ b/src/main/java/codesquad/configration/WebMvcConfig.java @@ -2,7 +2,7 @@ import codesquad.intercepter.AdminInterceptor; -import codesquad.security.ManagerAccountHandlerMethodArgumentResolver; +import codesquad.security.AdminAccountHandlerMethodArgumentResolver; import org.springframework.context.MessageSource; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -29,8 +29,8 @@ public PasswordEncoder passwordEncoder() { } @Bean - public ManagerAccountHandlerMethodArgumentResolver managerAccountHandlerMethodArgumentResolver() { - return new ManagerAccountHandlerMethodArgumentResolver(); + public AdminAccountHandlerMethodArgumentResolver managerAccountHandlerMethodArgumentResolver() { + return new AdminAccountHandlerMethodArgumentResolver(); } @Override diff --git a/src/main/java/codesquad/domain/AccountType.java b/src/main/java/codesquad/domain/AccountType.java index e7f3657..8927fbc 100644 --- a/src/main/java/codesquad/domain/AccountType.java +++ b/src/main/java/codesquad/domain/AccountType.java @@ -2,15 +2,15 @@ public enum AccountType { MEMBER(false), - MANAGER(true); + ADMIN(true); - boolean isManager; + boolean isAdmin; - AccountType(boolean isManager) { - this.isManager = isManager; + AccountType(boolean isAdmin) { + this.isAdmin = isAdmin; } - public boolean isManager() { - return isManager; + public boolean isAdmin() { + return isAdmin; } } diff --git a/src/main/java/codesquad/intercepter/AdminInterceptor.java b/src/main/java/codesquad/intercepter/AdminInterceptor.java index bea49f4..3f07399 100644 --- a/src/main/java/codesquad/intercepter/AdminInterceptor.java +++ b/src/main/java/codesquad/intercepter/AdminInterceptor.java @@ -20,7 +20,7 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons } Account account = (Account) loginAccount; - if (!account.getType().isManager()) { + if (!account.getType().isAdmin()) { throw new UnAuthorizedException("you're not manager"); } return true; diff --git a/src/main/java/codesquad/security/ManagerAccount.java b/src/main/java/codesquad/security/AdminAccount.java similarity index 72% rename from src/main/java/codesquad/security/ManagerAccount.java rename to src/main/java/codesquad/security/AdminAccount.java index 7b4c8f2..21e2552 100644 --- a/src/main/java/codesquad/security/ManagerAccount.java +++ b/src/main/java/codesquad/security/AdminAccount.java @@ -1,8 +1,6 @@ package codesquad.security; -import org.springframework.beans.factory.annotation.Required; - import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -10,5 +8,5 @@ @Target(ElementType.PARAMETER) @Retention(RetentionPolicy.RUNTIME) -public @interface ManagerAccount { +public @interface AdminAccount { } \ No newline at end of file diff --git a/src/main/java/codesquad/security/ManagerAccountHandlerMethodArgumentResolver.java b/src/main/java/codesquad/security/AdminAccountHandlerMethodArgumentResolver.java similarity index 82% rename from src/main/java/codesquad/security/ManagerAccountHandlerMethodArgumentResolver.java rename to src/main/java/codesquad/security/AdminAccountHandlerMethodArgumentResolver.java index d5aebca..aefab95 100644 --- a/src/main/java/codesquad/security/ManagerAccountHandlerMethodArgumentResolver.java +++ b/src/main/java/codesquad/security/AdminAccountHandlerMethodArgumentResolver.java @@ -9,10 +9,10 @@ import org.springframework.web.method.support.HandlerMethodArgumentResolver; import org.springframework.web.method.support.ModelAndViewContainer; -public class ManagerAccountHandlerMethodArgumentResolver implements HandlerMethodArgumentResolver { +public class AdminAccountHandlerMethodArgumentResolver implements HandlerMethodArgumentResolver { @Override public boolean supportsParameter(MethodParameter methodParameter) { - return methodParameter.hasParameterAnnotation(ManagerAccount.class); + return methodParameter.hasParameterAnnotation(AdminAccount.class); } @Override @@ -21,7 +21,7 @@ public Object resolveArgument(MethodParameter methodParameter, NativeWebRequest nativeWebRequest, WebDataBinderFactory webDataBinderFactory) throws Exception { Account account = SessionUtils.getUserFromSession(nativeWebRequest); - if (!account.getType().isManager()) { + if (!account.getType().isAdmin()) { throw new UnAuthorizedException("You're not manager!"); } return account; diff --git a/src/main/java/codesquad/web/ApiMenuCategoryController.java b/src/main/java/codesquad/web/ApiMenuCategoryController.java index b34f930..d536341 100644 --- a/src/main/java/codesquad/web/ApiMenuCategoryController.java +++ b/src/main/java/codesquad/web/ApiMenuCategoryController.java @@ -2,7 +2,7 @@ import codesquad.domain.Account; import codesquad.domain.MenuCategory; -import codesquad.security.ManagerAccount; +import codesquad.security.AdminAccount; import codesquad.service.MenuCategoryService; import codesquad.web.dto.MenuCategoryDTO; import org.springframework.beans.factory.annotation.Autowired; @@ -26,13 +26,13 @@ public List getCategories() { } @PostMapping("") - public ResponseEntity create(@ManagerAccount Account manager, @RequestBody MenuCategoryDTO menuCategoryDTO) { + public ResponseEntity create(@AdminAccount Account manager, @RequestBody MenuCategoryDTO menuCategoryDTO) { MenuCategory createdCategory = menuCategoryService.create(menuCategoryDTO); return makeCreatedResponseEntity(createdCategory); } @DeleteMapping("/{id}") - public MenuCategory delete(@ManagerAccount Account manager, @PathVariable Long id) { + public MenuCategory delete(@AdminAccount Account manager, @PathVariable Long id) { return menuCategoryService.deleteById(id); } } diff --git a/src/main/resources/application-local.properties b/src/main/resources/application-local.properties new file mode 100755 index 0000000..f17ee14 --- /dev/null +++ b/src/main/resources/application-local.properties @@ -0,0 +1,6 @@ +spring.jpa.hibernate.ddl-auto=create + +spring.jpa.show-sql=true +spring.jpa.properties.hibernate.format_sql=true +logging.level.org.hibernate.type.descriptor.sql=trace + diff --git a/src/main/resources/application-prod.properties b/src/main/resources/application-prod.properties new file mode 100644 index 0000000..7ea3d03 --- /dev/null +++ b/src/main/resources/application-prod.properties @@ -0,0 +1,8 @@ +spring.datasource.url=jdbc:mysql://localhost:3306/springboot?useSSL=false&allowPublicKeyRetrieval=true +spring.datasource.username=minseok +spring.datasource.password=password + +log4j.logger.org.hibernate.type=info + +spring.jpa.hibernate.ddl-auto=validate + diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index a5dd2b0..f0b0897 100755 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,15 +1,6 @@ +spring.autoconfigure.exclude= org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration +spring.profiles.active=local +logging.config=classpath:logback-${spring.profiles.active}.xml handlebars.suffix=.hbs handlebars.cache=false -handlebars.expose-session-attributes=true - -spring.datasource.url=jdbc:mysql://localhost:3306/springboot?useSSL=false&allowPublicKeyRetrieval=true -spring.datasource.username=minseok -spring.datasource.password=password -spring.jpa.hibernate.ddl-auto=create - -spring.jpa.show-sql=true -spring.jpa.properties.hibernate.format_sql=true -logging.level.org.hibernate.type.descriptor.sql=trace -log4j.logger.org.hibernate.type=debug - -spring.autoconfigure.exclude= org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration \ No newline at end of file +handlebars.expose-session-attributes=true \ No newline at end of file diff --git a/src/main/resources/import.sql b/src/main/resources/import.sql index 80f0473..bca9bef 100644 --- a/src/main/resources/import.sql +++ b/src/main/resources/import.sql @@ -1,5 +1,5 @@ INSERT INTO account (id, user_id, password, name, email, phone_number, type ,create_at) values (1, 'test@google.com', '$2a$10$75iOIZVohML12YADpMEqre39yvfFQWn8PkoCf0VMct6ItcVVb77B.', '자바지기', 'javajigi@slipp.net', '010-1111-1111', 'MEMBER', CURRENT_TIMESTAMP()); -INSERT INTO account (id, user_id, password, name, email, phone_number, type ,create_at) values (2, 'admin@admin.com', '$2a$10$75iOIZVohML12YADpMEqre39yvfFQWn8PkoCf0VMct6ItcVVb77B.', '관리자', 'admin@admin.com', '010-1111-1111', 'MANAGER', CURRENT_TIMESTAMP()); +INSERT INTO account (id, user_id, password, name, email, phone_number, type ,create_at) values (2, 'admin@admin.com', '$2a$10$75iOIZVohML12YADpMEqre39yvfFQWn8PkoCf0VMct6ItcVVb77B.', '관리자', 'admin@admin.com', '010-1111-1111', 'ADMIN', CURRENT_TIMESTAMP()); INSERT INTO menu_category (name, parent_id, id, create_at) values ('밑반찬', NULL, 1, CURRENT_TIMESTAMP()); INSERT INTO menu_category (name, parent_id, id, create_at) values ('무침', 1, 2, CURRENT_TIMESTAMP()); diff --git a/src/main/resources/logback-local.xml b/src/main/resources/logback-local.xml new file mode 100644 index 0000000..e057b0d --- /dev/null +++ b/src/main/resources/logback-local.xml @@ -0,0 +1,12 @@ + + + + + %d{yyyy-MM-dd HH:mm:ss.SSS}[%-5level] : %msg%n + + + + + + + diff --git a/src/main/resources/logback-prod.xml b/src/main/resources/logback-prod.xml new file mode 100644 index 0000000..c90368c --- /dev/null +++ b/src/main/resources/logback-prod.xml @@ -0,0 +1,30 @@ + + + + + %d{yyyy-MM-dd HH:mm:ss.SSS}[%-5level] : %msg%n + + + + + INFO + + mylog.txt + + + mylog-%d{yyyy-MM-dd}.%i.txt + + + 100MB + + + + [%-5level] %d{HH:mm:ss.SSS} %logger{36} - %msg%n + + + + + + + \ No newline at end of file diff --git a/src/main/resources/static/css/main.css b/src/main/resources/static/css/main.css index 417b06d..1f382e5 100644 --- a/src/main/resources/static/css/main.css +++ b/src/main/resources/static/css/main.css @@ -1427,11 +1427,36 @@ a:focus { right: 0; top: 0; bottom: 0; + visibility: hidden; background-repeat: no-repeat; background-size: cover; background-position: center center; } +#main-visual .img-box .visible{ + visibility: visible; +} + +#main-visual .img-box .prev { + transform: translateX(-100%); + transition: transform 1s; + z-index: -1; + +} + +#main-visual .img-box .current { + transform: none; + transition: transform 1s; +} + +#main-visual .img-box .next { + z-index: -1; + transition: transform 1s; + transform: translateX(100%); +} + + + #main-visual .img-box .img-1 { background-image: url(../img/img-main-visual-slide_1.jpg); } diff --git a/src/main/resources/static/js/main.js b/src/main/resources/static/js/main.js new file mode 100644 index 0000000..788e968 --- /dev/null +++ b/src/main/resources/static/js/main.js @@ -0,0 +1,67 @@ +let sliderCount; +let sliderIndex = 0; +let slider; +let sliderDots; +window.onload = function () { + sliderCount = document.querySelector("ul.img-box").children.length; + slider = document.querySelectorAll(".img-box li.img-item"); + sliderDots = document.querySelector(".dot-btn-box").children; + document.querySelector(".bm-icon.spr-btn-arrow-main-slide.next").addEventListener("click", next); + document.querySelector(".bm-icon.spr-btn-arrow-main-slide.prev").addEventListener("click", prev); +} + +const next = function (e) { + removeClasses(); + sliderIndex = toNext(sliderIndex); + addNextClasses(); +} + +const prev = function (e) { + removeClasses(); + sliderIndex = toPrev(sliderIndex); + addPrevClasses(); +} + +function toPrev(index) { + return (index - 1 + 5) % sliderCount; +} + +function toNext(index) { + return (index +1 ) % sliderCount; +} + +function removeClasses() { + removeAllVisible(); + slider[toPrev(sliderIndex)].classList.remove("prev"); + slider[sliderIndex].classList.remove("current"); + slider[toNext(sliderIndex)].classList.remove("next"); + + sliderDots[sliderIndex].classList.remove("on"); +} + +function removeAllVisible() { + for(let i=0; i주요 프로모션
    -
  • +
  • 장윤주 식단 대공개! 그녀의 건강 반찬을 소개합니다. @@ -838,6 +838,7 @@ + \ No newline at end of file diff --git a/src/test/java/codesquad/web/ApiMenuCategoryControllerTest.java b/src/test/java/codesquad/web/ApiMenuCategoryControllerTest.java index 94bf96b..4f3b191 100644 --- a/src/test/java/codesquad/web/ApiMenuCategoryControllerTest.java +++ b/src/test/java/codesquad/web/ApiMenuCategoryControllerTest.java @@ -3,7 +3,7 @@ import codesquad.domain.Account; import codesquad.domain.AccountType; import codesquad.domain.MenuCategory; -import codesquad.security.ManagerAccountHandlerMethodArgumentResolver; +import codesquad.security.AdminAccountHandlerMethodArgumentResolver; import codesquad.service.MenuCategoryService; import codesquad.web.dto.MenuCategoryDTO; import com.fasterxml.jackson.databind.ObjectMapper; @@ -48,9 +48,9 @@ public class ApiMenuCategoryControllerTest { private MenuCategoryService menuCategoryService; @Mock - private ManagerAccountHandlerMethodArgumentResolver managerArgumentResolver; + private AdminAccountHandlerMethodArgumentResolver managerArgumentResolver; - private MockManagerArgumentResolver mockManagerArgumentResolver = new MockManagerArgumentResolver(); + private MockAdminArgumentResolver mockManagerArgumentResolver = new MockAdminArgumentResolver(); private JacksonTester jsonMenuCategoryDTO; @@ -77,7 +77,7 @@ public void setup() { categories.add(fstCategory); categories.add(new MenuCategory(null, "카테고리2")); - manager = new Account("manager@gmail.com", "!Password1234", "manager", "manager@gmail.com", AccountType.MANAGER); + manager = new Account("manager@gmail.com", "!Password1234", "manager", "manager@gmail.com", AccountType.ADMIN); } @Test @@ -139,14 +139,14 @@ public void deleteCategoryTest() throws Exception { assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value()); } - static class MockManagerArgumentResolver extends ManagerAccountHandlerMethodArgumentResolver { + static class MockAdminArgumentResolver extends AdminAccountHandlerMethodArgumentResolver { @Override public Object resolveArgument(MethodParameter methodParameter, ModelAndViewContainer modelAndViewContainer, NativeWebRequest nativeWebRequest, WebDataBinderFactory webDataBinderFactory) throws Exception { - return new Account("managerByMock@gmail.com", "!Password1234", "manager", "manager@gmail.com", AccountType.MANAGER); + return new Account("managerByMock@gmail.com", "!Password1234", "manager", "manager@gmail.com", AccountType.ADMIN); } } } \ No newline at end of file From c577f670625a46d355ba23e0860dfec314137bf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8C=E1=85=A5=E1=86=BC=E1=84=86=E1=85=B5=E1=86=AB?= =?UTF-8?q?=E1=84=89=E1=85=A5=E1=86=A8?= Date: Fri, 3 May 2019 03:05:51 +0900 Subject: [PATCH 02/21] =?UTF-8?q?feature=20:=20AcceptanceTest=20=EB=B6=80?= =?UTF-8?q?=EB=AA=A8=ED=81=B4=EB=9E=98=EC=8A=A4=20=EC=83=9D=EC=84=B1,=20Ba?= =?UTF-8?q?sicAuthIntercepter=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../intercepter/BasicAuthInterceptor.java | 61 +++++++++++++++++++ .../BasicAuthenticationIntercepter.java | 12 ---- src/main/resources/logback-local.xml | 2 +- src/main/resources/logback-prod.xml | 2 +- .../acceptance/CategoryAcceptanceTest.java | 15 ++--- .../security/BasicAuthInterceptorTest.java | 58 ++++++++++++++++++ .../java/support/test/AcceptanceTest.java | 48 +++++++++++++-- 7 files changed, 173 insertions(+), 25 deletions(-) create mode 100644 src/main/java/codesquad/intercepter/BasicAuthInterceptor.java delete mode 100644 src/main/java/codesquad/intercepter/BasicAuthenticationIntercepter.java create mode 100644 src/test/java/support/security/BasicAuthInterceptorTest.java diff --git a/src/main/java/codesquad/intercepter/BasicAuthInterceptor.java b/src/main/java/codesquad/intercepter/BasicAuthInterceptor.java new file mode 100644 index 0000000..51c2a8b --- /dev/null +++ b/src/main/java/codesquad/intercepter/BasicAuthInterceptor.java @@ -0,0 +1,61 @@ +package codesquad.intercepter; + +import codesquad.domain.Account; +import codesquad.domain.AccountRepository; +import codesquad.exception.account.UnAuthenticationException; +import codesquad.util.SessionUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.nio.charset.Charset; +import java.util.Base64; + +public class BasicAuthInterceptor extends HandlerInterceptorAdapter { + + private static final Logger log = LoggerFactory.getLogger(BasicAuthInterceptor.class); + + @Autowired + private AccountRepository accountRepository; + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { + String base64Credentials; + try{ + base64Credentials = getEncodedCredentials(request); + String[] credentialValues = getDecodedCredentials(base64Credentials); + String userId = credentialValues[0]; + String password = credentialValues[1]; + log.debug("userId : {}", userId); + log.debug("password : {}", password); + login(request, userId, password); + return true; + }catch (UnAuthenticationException e){ + return true; + } + } + + public String getEncodedCredentials(HttpServletRequest request){ + String authorization = request.getHeader("Authorization"); + if(authorization==null || !authorization.startsWith("Basic")){ + throw new UnAuthenticationException(); + } + return authorization.substring("Basic".length()).trim(); + } + + public String[] getDecodedCredentials(String base64Credentials) { + String credentials = new String(Base64.getDecoder().decode(base64Credentials), Charset.forName("UTF-8")); + return credentials.split(":",2); + } + + public void login(HttpServletRequest request, String userId, String password) { + Account account = accountRepository.findByUserId(userId).orElseThrow(UnAuthenticationException::new); + + if(account.matchPassword(password)){ + request.getSession().setAttribute(SessionUtils.USER_SESSION_KEY, account); + } + } +} diff --git a/src/main/java/codesquad/intercepter/BasicAuthenticationIntercepter.java b/src/main/java/codesquad/intercepter/BasicAuthenticationIntercepter.java deleted file mode 100644 index d8e33d4..0000000 --- a/src/main/java/codesquad/intercepter/BasicAuthenticationIntercepter.java +++ /dev/null @@ -1,12 +0,0 @@ -package codesquad.intercepter; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; - -public class BasicAuthenticationIntercepter extends HandlerInterceptorAdapter { - - private static final Logger log = LoggerFactory.getLogger(BasicAuthenticationIntercepter.class); - -} diff --git a/src/main/resources/logback-local.xml b/src/main/resources/logback-local.xml index e057b0d..cc4101d 100644 --- a/src/main/resources/logback-local.xml +++ b/src/main/resources/logback-local.xml @@ -2,7 +2,7 @@ - %d{yyyy-MM-dd HH:mm:ss.SSS}[%-5level] : %msg%n + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n diff --git a/src/main/resources/logback-prod.xml b/src/main/resources/logback-prod.xml index c90368c..0a52feb 100644 --- a/src/main/resources/logback-prod.xml +++ b/src/main/resources/logback-prod.xml @@ -2,7 +2,7 @@ - %d{yyyy-MM-dd HH:mm:ss.SSS}[%-5level] : %msg%n + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n diff --git a/src/test/java/codesquad/acceptance/CategoryAcceptanceTest.java b/src/test/java/codesquad/acceptance/CategoryAcceptanceTest.java index c2c324f..9e87a12 100644 --- a/src/test/java/codesquad/acceptance/CategoryAcceptanceTest.java +++ b/src/test/java/codesquad/acceptance/CategoryAcceptanceTest.java @@ -23,7 +23,6 @@ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = RANDOM_PORT) public class CategoryAcceptanceTest extends AcceptanceTest { - //TODO : BasicAuthorizationInterceptor를 통한 AcceptanceTest구현 private static Logger log = LoggerFactory.getLogger(CategoryAcceptanceTest.class); @Autowired @@ -31,7 +30,6 @@ public class CategoryAcceptanceTest extends AcceptanceTest { private static BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(); - @Test public void index_test() { ResponseEntity reponse = sendGet("/", String.class); @@ -52,7 +50,8 @@ public void api_create_test() { MenuCategoryDTO category = new MenuCategoryDTO(); category.setName("새로운 자식"); category.setParentId(1l); - ResponseEntity response = sendPost("/api/menuCategory", category, MenuCategory.class); + ResponseEntity response = + sendPostWithDefaultManager("/api/menuCategory", category, MenuCategory.class); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.CREATED); assertThat(response.getBody().getName()).isEqualTo("새로운 자식"); @@ -62,7 +61,8 @@ public void api_create_test() { public void api_create_category_test() { MenuCategoryDTO category = new MenuCategoryDTO(); category.setName("새로운 카테고리"); - ResponseEntity response = sendPost("/api/menuCategory", category, MenuCategory.class); + ResponseEntity response = + sendPostWithDefaultManager("/api/menuCategory", category, MenuCategory.class); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.CREATED); assertThat(response.getBody().getName()).isEqualTo("새로운 카테고리"); @@ -72,9 +72,10 @@ public void api_create_category_test() { public void api_delete_test() { MenuCategoryDTO category = new MenuCategoryDTO(); category.setName("새로운 삭제된 카테고리"); - ResponseEntity responseByPost = sendPost("/api/menuCategory", category, MenuCategory.class); - - ResponseEntity responseByDelete = sendDelete("/api/menuCategory/" + responseByPost.getBody().getId(), MenuCategory.class); + ResponseEntity responseByPost = + sendPostWithDefaultManager("/api/menuCategory", category, MenuCategory.class); + ResponseEntity responseByDelete = + sendDeleteWithDefaultManager("/api/menuCategory/" + responseByPost.getBody().getId(), MenuCategory.class); assertThat(responseByDelete.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(responseByDelete.getBody().getName()).isEqualTo("새로운 삭제된 카테고리"); diff --git a/src/test/java/support/security/BasicAuthInterceptorTest.java b/src/test/java/support/security/BasicAuthInterceptorTest.java new file mode 100644 index 0000000..cc4e23c --- /dev/null +++ b/src/test/java/support/security/BasicAuthInterceptorTest.java @@ -0,0 +1,58 @@ +package support.security; + +import codesquad.domain.Account; +import codesquad.domain.AccountRepository; +import codesquad.intercepter.BasicAuthInterceptor; +import codesquad.service.AccountService; +import codesquad.util.SessionUtils; +import codesquad.web.dto.AccountLoginDTO; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.security.crypto.password.PasswordEncoder; + +import java.util.Base64; +import java.util.Optional; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; +import static org.mockito.Mockito.when; + +@RunWith(MockitoJUnitRunner.class) +public class BasicAuthInterceptorTest { + + @Mock + private AccountRepository accountRepository; + + @InjectMocks + private BasicAuthInterceptor basicAuthInterceptor; + + @Test + public void preHandleTest() throws Exception { + //given + String userId = "userId"; + String password = "password"; + MockHttpServletRequest request = basicAuthHttpRequest(userId, password); + Account loginAccount = new Account(userId, password, "name", "javajigi@slipp.net"); + when(accountRepository.findByUserId(userId)).thenReturn(Optional.of(loginAccount)); + + //when + basicAuthInterceptor.preHandle(request, null, null); + + //then + assertThat(request.getSession().getAttribute(SessionUtils.USER_SESSION_KEY), is(loginAccount)); + + } + + private MockHttpServletRequest basicAuthHttpRequest(String userId, String password) { + String encodedBasicAuth = Base64.getEncoder() + .encodeToString(String.format("%s:%s", userId, password).getBytes()); + MockHttpServletRequest request = new MockHttpServletRequest(); + request.addHeader("Authorization", "Basic " + encodedBasicAuth); + return request; + } +} diff --git a/src/test/java/support/test/AcceptanceTest.java b/src/test/java/support/test/AcceptanceTest.java index d532125..b88741e 100644 --- a/src/test/java/support/test/AcceptanceTest.java +++ b/src/test/java/support/test/AcceptanceTest.java @@ -1,24 +1,64 @@ package support.test; +import codesquad.domain.Account; +import codesquad.domain.AccountRepository; +import codesquad.exception.account.UnAuthenticationException; +import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.http.*; +import org.springframework.test.context.junit4.SpringRunner; +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class AcceptanceTest { + private static final String DEFAULT_MANAGER_ACCOUNT_EMAIL = "admin@admin.com"; @Autowired - TestRestTemplate template; + private TestRestTemplate testRestTemplate; + + @Autowired + private AccountRepository accountRepository; + + public TestRestTemplate template(){ + return testRestTemplate; + } + + public TestRestTemplate basicAuthTemplate(){ + return basicAuthTemplate(getDefaultManager()); + } + + private Account getDefaultManager() { + return accountRepository.findByUserId(DEFAULT_MANAGER_ACCOUNT_EMAIL).orElseThrow(UnAuthenticationException::new); + } + + public TestRestTemplate basicAuthTemplate(Account account){ + return testRestTemplate.withBasicAuth(account.getUserId(), account.getPassword()); + } protected ResponseEntity sendPost(String uri, Object object, Class responseType) { - return template.exchange(uri, HttpMethod.POST, createHttpEntity(object), responseType); + return template().exchange(uri, HttpMethod.POST, createHttpEntity(object), responseType); } protected ResponseEntity sendGet(String uri, Class responseType) { - return template.getForEntity(uri, responseType); + return template().getForEntity(uri, responseType); } protected ResponseEntity sendDelete(String uri, Class responseType) { - return template.exchange(uri, HttpMethod.DELETE, createHttpEntity(null), responseType); + return template().exchange(uri, HttpMethod.DELETE, createHttpEntity(null), responseType); + } + + protected ResponseEntity sendPostWithDefaultManager(String uri, Object object, Class responseType) { + return basicAuthTemplate().exchange(uri, HttpMethod.POST, createHttpEntity(object), responseType); + } + + protected ResponseEntity sendGetWithDefaultManager(String uri, Class responseType) { + return basicAuthTemplate().getForEntity(uri, responseType); + } + + protected ResponseEntity sendDeleteWithDefaultManager(String uri, Class responseType) { + return basicAuthTemplate().exchange(uri, HttpMethod.DELETE, createHttpEntity(null), responseType); } protected HttpEntity createHttpEntity(Object object) { From b53da286ea0286bc44fcc96316af115fde30cc25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8C=E1=85=A5=E1=86=BC=E1=84=86=E1=85=B5=E1=86=AB?= =?UTF-8?q?=E1=84=89=E1=85=A5=E1=86=A8?= Date: Fri, 3 May 2019 04:05:43 +0900 Subject: [PATCH 03/21] =?UTF-8?q?feature=20:=20test=20profile=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../codesquad/configration/WebMvcConfig.java | 19 ++++++++++++ .../intercepter/BasicAuthInterceptor.java | 1 - .../application-development.properties | 9 ++++++ .../resources/application-prod.properties | 1 + src/main/resources/application.properties | 9 ++++-- src/main/resources/logback-development.xml | 30 +++++++++++++++++++ .../{logback-local.xml => logback.xml} | 0 src/test/resources/application.properties | 9 ++++++ 8 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 src/main/resources/application-development.properties create mode 100644 src/main/resources/logback-development.xml rename src/main/resources/{logback-local.xml => logback.xml} (100%) create mode 100755 src/test/resources/application.properties diff --git a/src/main/java/codesquad/configration/WebMvcConfig.java b/src/main/java/codesquad/configration/WebMvcConfig.java index b16c0f0..46f142b 100644 --- a/src/main/java/codesquad/configration/WebMvcConfig.java +++ b/src/main/java/codesquad/configration/WebMvcConfig.java @@ -2,10 +2,12 @@ import codesquad.intercepter.AdminInterceptor; +import codesquad.intercepter.BasicAuthInterceptor; import codesquad.security.AdminAccountHandlerMethodArgumentResolver; import org.springframework.context.MessageSource; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; import org.springframework.context.support.MessageSourceAccessor; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.password.PasswordEncoder; @@ -33,11 +35,28 @@ public AdminAccountHandlerMethodArgumentResolver managerAccountHandlerMethodArgu return new AdminAccountHandlerMethodArgumentResolver(); } + @Configuration + @Profile("test") + public class TestWebMvcConfig extends WebMvcConfig{ + + @Override + public void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor(new AdminInterceptor()) + .addPathPatterns("/admin"); + registry.addInterceptor(basicAuthInterceptor()); + } + } + @Override public void addArgumentResolvers(List argumentResolvers) { argumentResolvers.add(managerAccountHandlerMethodArgumentResolver()); } + @Bean + public BasicAuthInterceptor basicAuthInterceptor(){ + return new BasicAuthInterceptor(); + } + @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(new AdminInterceptor()) diff --git a/src/main/java/codesquad/intercepter/BasicAuthInterceptor.java b/src/main/java/codesquad/intercepter/BasicAuthInterceptor.java index 51c2a8b..338b746 100644 --- a/src/main/java/codesquad/intercepter/BasicAuthInterceptor.java +++ b/src/main/java/codesquad/intercepter/BasicAuthInterceptor.java @@ -15,7 +15,6 @@ import java.util.Base64; public class BasicAuthInterceptor extends HandlerInterceptorAdapter { - private static final Logger log = LoggerFactory.getLogger(BasicAuthInterceptor.class); @Autowired diff --git a/src/main/resources/application-development.properties b/src/main/resources/application-development.properties new file mode 100644 index 0000000..5833cf5 --- /dev/null +++ b/src/main/resources/application-development.properties @@ -0,0 +1,9 @@ +spring.datasource.url=jdbc:mysql://localhost:3306/springboot?useSSL=false&allowPublicKeyRetrieval=true +spring.datasource.username=minseok +spring.datasource.password=password + +log4j.logger.org.hibernate.type=info + +spring.jpa.hibernate.ddl-auto=validate + +logging.config=classpath:logback-${spring.profiles.active}.xml diff --git a/src/main/resources/application-prod.properties b/src/main/resources/application-prod.properties index 7ea3d03..5833cf5 100644 --- a/src/main/resources/application-prod.properties +++ b/src/main/resources/application-prod.properties @@ -6,3 +6,4 @@ log4j.logger.org.hibernate.type=info spring.jpa.hibernate.ddl-auto=validate +logging.config=classpath:logback-${spring.profiles.active}.xml diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index f0b0897..dba6802 100755 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,6 +1,9 @@ -spring.autoconfigure.exclude= org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration spring.profiles.active=local -logging.config=classpath:logback-${spring.profiles.active}.xml + +spring.autoconfigure.exclude= org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration + handlebars.suffix=.hbs handlebars.cache=false -handlebars.expose-session-attributes=true \ No newline at end of file +handlebars.expose-session-attributes=true + +logging.config=classpath:logback.xml diff --git a/src/main/resources/logback-development.xml b/src/main/resources/logback-development.xml new file mode 100644 index 0000000..0a52feb --- /dev/null +++ b/src/main/resources/logback-development.xml @@ -0,0 +1,30 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + INFO + + mylog.txt + + + mylog-%d{yyyy-MM-dd}.%i.txt + + + 100MB + + + + [%-5level] %d{HH:mm:ss.SSS} %logger{36} - %msg%n + + + + + + + \ No newline at end of file diff --git a/src/main/resources/logback-local.xml b/src/main/resources/logback.xml similarity index 100% rename from src/main/resources/logback-local.xml rename to src/main/resources/logback.xml diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties new file mode 100755 index 0000000..50fa960 --- /dev/null +++ b/src/test/resources/application.properties @@ -0,0 +1,9 @@ +spring.profiles.active=test + +spring.autoconfigure.exclude= org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration + +handlebars.suffix=.hbs +handlebars.cache=false +handlebars.expose-session-attributes=true + +logging.config=classpath:logback.xml From 06ad55d942836f260732fb03b606dd4d108eb97f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8C=E1=85=A5=E1=86=BC=E1=84=86=E1=85=B5=E1=86=AB?= =?UTF-8?q?=E1=84=89=E1=85=A5=E1=86=A8?= Date: Fri, 3 May 2019 21:29:30 +0900 Subject: [PATCH 04/21] =?UTF-8?q?feature=20:=20=EB=B9=8C=EB=93=9C=20?= =?UTF-8?q?=EC=9E=90=EB=8F=99=ED=99=94=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/codesquad/configration/WebMvcConfig.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/codesquad/configration/WebMvcConfig.java b/src/main/java/codesquad/configration/WebMvcConfig.java index 46f142b..a69d22b 100644 --- a/src/main/java/codesquad/configration/WebMvcConfig.java +++ b/src/main/java/codesquad/configration/WebMvcConfig.java @@ -41,8 +41,6 @@ public class TestWebMvcConfig extends WebMvcConfig{ @Override public void addInterceptors(InterceptorRegistry registry) { - registry.addInterceptor(new AdminInterceptor()) - .addPathPatterns("/admin"); registry.addInterceptor(basicAuthInterceptor()); } } From f38a888ab6637525a7941a6c0ee4a33f2a8d0d0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8C=E1=85=A5=E1=86=BC=E1=84=86=E1=85=B5=E1=86=AB?= =?UTF-8?q?=E1=84=89=E1=85=A5=E1=86=A8?= Date: Fri, 3 May 2019 22:19:36 +0900 Subject: [PATCH 05/21] fix : text failure fix --- .../JpaEnableConfiguration.java | 2 +- .../WebMvcConfig.java | 13 ++- src/test/java/codesquad/ApplicationTest.java | 16 ++++ .../domain/AccountRepositoryTest.java | 11 ++- .../codesquad/domain/AccountValidTest.java | 4 +- .../domain/MenuCategoryRepositoryTest.java | 4 +- .../web/ApiMenuCategoryControllerTest.java | 9 -- ...yControllerWithApplicationContextTest.java | 85 ------------------- 8 files changed, 38 insertions(+), 106 deletions(-) rename src/main/java/codesquad/{configration => configuration}/JpaEnableConfiguration.java (90%) rename src/main/java/codesquad/{configration => configuration}/WebMvcConfig.java (86%) create mode 100644 src/test/java/codesquad/ApplicationTest.java delete mode 100644 src/test/java/codesquad/web/ApiMenuCategoryControllerWithApplicationContextTest.java diff --git a/src/main/java/codesquad/configration/JpaEnableConfiguration.java b/src/main/java/codesquad/configuration/JpaEnableConfiguration.java similarity index 90% rename from src/main/java/codesquad/configration/JpaEnableConfiguration.java rename to src/main/java/codesquad/configuration/JpaEnableConfiguration.java index d1cc3e6..53bd428 100644 --- a/src/main/java/codesquad/configration/JpaEnableConfiguration.java +++ b/src/main/java/codesquad/configuration/JpaEnableConfiguration.java @@ -1,4 +1,4 @@ -package codesquad.configration; +package codesquad.configuration; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; diff --git a/src/main/java/codesquad/configration/WebMvcConfig.java b/src/main/java/codesquad/configuration/WebMvcConfig.java similarity index 86% rename from src/main/java/codesquad/configration/WebMvcConfig.java rename to src/main/java/codesquad/configuration/WebMvcConfig.java index a69d22b..d7f4863 100644 --- a/src/main/java/codesquad/configration/WebMvcConfig.java +++ b/src/main/java/codesquad/configuration/WebMvcConfig.java @@ -1,4 +1,4 @@ -package codesquad.configration; +package codesquad.configuration; import codesquad.intercepter.AdminInterceptor; @@ -39,6 +39,11 @@ public AdminAccountHandlerMethodArgumentResolver managerAccountHandlerMethodArgu @Profile("test") public class TestWebMvcConfig extends WebMvcConfig{ + @Bean + public BasicAuthInterceptor basicAuthInterceptor(){ + return new BasicAuthInterceptor(); + } + @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(basicAuthInterceptor()); @@ -51,13 +56,13 @@ public void addArgumentResolvers(List argumentRes } @Bean - public BasicAuthInterceptor basicAuthInterceptor(){ - return new BasicAuthInterceptor(); + public AdminInterceptor adminInterceptor(){ + return new AdminInterceptor(); } @Override public void addInterceptors(InterceptorRegistry registry) { - registry.addInterceptor(new AdminInterceptor()) + registry.addInterceptor(adminInterceptor()) .addPathPatterns("/admin"); } } diff --git a/src/test/java/codesquad/ApplicationTest.java b/src/test/java/codesquad/ApplicationTest.java new file mode 100644 index 0000000..ad8893f --- /dev/null +++ b/src/test/java/codesquad/ApplicationTest.java @@ -0,0 +1,16 @@ +package codesquad; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class ApplicationTest { + + @Test + public void contextLoads() { + } + +} \ No newline at end of file diff --git a/src/test/java/codesquad/domain/AccountRepositoryTest.java b/src/test/java/codesquad/domain/AccountRepositoryTest.java index 5ca8a60..2eb22b3 100644 --- a/src/test/java/codesquad/domain/AccountRepositoryTest.java +++ b/src/test/java/codesquad/domain/AccountRepositoryTest.java @@ -4,27 +4,32 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.test.context.junit4.SpringRunner; +import sun.security.util.Password; import static org.assertj.core.api.Assertions.assertThat; @RunWith(SpringRunner.class) @DataJpaTest +@ComponentScan({"support"}) public class AccountRepositoryTest { @Autowired AccountRepository accountRepository; + private PasswordEncoder encoder= new BCryptPasswordEncoder(); + @Test public void saveTest() { - Account account = new Account("test1@google.com", "!Password1234", "자바지기", "dadadamared@ng.com"); - accountRepository.save(account); assertThat(accountRepository.findAll().size()).isEqualTo(2); } @Test public void findByUserIdTest() { - assertThat(accountRepository.findByUserId("test@google.com").get().getPassword()).isEqualTo("!Password1234"); + assertThat(encoder.matches("!Test1234", accountRepository.findByUserId("test@google.com").get().getPassword())).isEqualTo(true); } } \ No newline at end of file diff --git a/src/test/java/codesquad/domain/AccountValidTest.java b/src/test/java/codesquad/domain/AccountValidTest.java index d64694f..64dba65 100644 --- a/src/test/java/codesquad/domain/AccountValidTest.java +++ b/src/test/java/codesquad/domain/AccountValidTest.java @@ -14,7 +14,7 @@ public class AccountValidTest { - private static final Logger log = LoggerFactory.getLogger(AccountTest.class); + private static final Logger log = LoggerFactory.getLogger(AccountValidTest.class); private static Validator validator; @@ -25,7 +25,7 @@ public static void setup() { @Test public void emptyUserId() { - Account user = new Account("", "12345678", "testName", "test@gmail.com"); + Account user = new Account("", "!Ta12345678", "testName", "test@gmail.com"); Set> constraintViolations = validator.validate(user); assertThat(constraintViolations.size()).isEqualTo(1); diff --git a/src/test/java/codesquad/domain/MenuCategoryRepositoryTest.java b/src/test/java/codesquad/domain/MenuCategoryRepositoryTest.java index 4e0aca8..8d2601f 100644 --- a/src/test/java/codesquad/domain/MenuCategoryRepositoryTest.java +++ b/src/test/java/codesquad/domain/MenuCategoryRepositoryTest.java @@ -24,7 +24,7 @@ public class MenuCategoryRepositoryTest { public void defualt_test() { MenuCategory menuCategory = new MenuCategory(1L, "최상"); categoryRepository.save(menuCategory); - assertThat(categoryRepository.findAll().size()).isEqualTo(19); + assertThat(categoryRepository.findAll().size()).isEqualTo(18); } @Test @@ -60,7 +60,7 @@ public void delete_operate_test() { categoryRepository.delete(fstCategory); log.info("남은 카테고리 : '{}'", categoryRepository.findAll()); - assertThat(categoryRepository.findAll().size()).isEqualTo(14); + assertThat(categoryRepository.findAll().size()).isEqualTo(13); } } \ No newline at end of file diff --git a/src/test/java/codesquad/web/ApiMenuCategoryControllerTest.java b/src/test/java/codesquad/web/ApiMenuCategoryControllerTest.java index 4f3b191..e8ac4c9 100644 --- a/src/test/java/codesquad/web/ApiMenuCategoryControllerTest.java +++ b/src/test/java/codesquad/web/ApiMenuCategoryControllerTest.java @@ -32,7 +32,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.notNull; import static org.mockito.Mockito.when; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; @@ -120,14 +119,6 @@ public void deleteCategoryTest() throws Exception { //given when(menuCategoryService.deleteById(1l)) .thenReturn(new MenuCategory()); - when(managerArgumentResolver.supportsParameter((MethodParameter) notNull())) - .thenReturn(true); - when(managerArgumentResolver.resolveArgument( - (MethodParameter) notNull() - , (ModelAndViewContainer) notNull() - , (NativeWebRequest) notNull() - , (WebDataBinderFactory) notNull() - )).thenReturn(manager); //when MockHttpServletResponse response = mockMvc.perform( diff --git a/src/test/java/codesquad/web/ApiMenuCategoryControllerWithApplicationContextTest.java b/src/test/java/codesquad/web/ApiMenuCategoryControllerWithApplicationContextTest.java deleted file mode 100644 index c4d1a5b..0000000 --- a/src/test/java/codesquad/web/ApiMenuCategoryControllerWithApplicationContextTest.java +++ /dev/null @@ -1,85 +0,0 @@ -package codesquad.web; - -import codesquad.domain.MenuCategory; -import codesquad.service.MenuCategoryService; -import codesquad.web.dto.MenuCategoryDTO; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.boot.test.json.JacksonTester; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.mock.web.MockHttpServletResponse; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.web.servlet.MockMvc; - -import java.util.ArrayList; -import java.util.List; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; - -@RunWith(SpringRunner.class) -@WebMvcTest(value = ApiMenuCategoryController.class, secure = false) -public class ApiMenuCategoryControllerWithApplicationContextTest { - private static Logger log = LoggerFactory.getLogger(ApiMenuCategoryControllerWithApplicationContextTest.class); - - public static final String URI_MENU_CATEGORY = "/api/menuCategory"; - - @Autowired - private MockMvc mockMvc; - - @MockBean - private MenuCategoryService menuCategoryService; - - private JacksonTester jsonMenuCategoryDTO; - private JacksonTester jsonMenuCategory; - - private List categories = new ArrayList<>(); - - @Before - public void setup() { - JacksonTester.initFields(this, ObjectMapper::new); - - MenuCategory fstCategory = new MenuCategory(1l, "카테고리1"); - MenuCategory subCategory = new MenuCategory(2l, "카테고리1의 하위 카테고리"); - fstCategory.addChild(subCategory); - subCategory.setParent(fstCategory); - categories.add(fstCategory); - categories.add(new MenuCategory(3l, "카테고리2")); - } - - @Test - public void create_test_not_manager_fail() throws Exception { - //when - MockHttpServletResponse response = mockMvc.perform( - post(URI_MENU_CATEGORY) - .contentType(MediaType.APPLICATION_JSON) - .content(jsonMenuCategoryDTO.write( - new MenuCategoryDTO(0l, "카테고리2의 하위 카테고리", 3l)) - .getJson())) - .andReturn().getResponse(); - - //then - assertThat(response.getStatus()).isEqualTo(HttpStatus.FORBIDDEN.value()); - } - - @Test - public void delete_test_not_manager_fail() throws Exception { - //when - MockHttpServletResponse response = mockMvc.perform( - delete(URI_MENU_CATEGORY + "/{id}", 1l)) - .andReturn().getResponse(); - - //then - assertThat(response.getStatus()).isEqualTo(HttpStatus.FORBIDDEN.value()); - } - -} From 0b7cce52d1e3f8ff93fcdf6fdf5664fc9d0a4d06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8C=E1=85=A5=E1=86=BC=E1=84=86=E1=85=B5=E1=86=AB?= =?UTF-8?q?=E1=84=89=E1=85=A5=E1=86=A8?= Date: Fri, 3 May 2019 22:24:41 +0900 Subject: [PATCH 06/21] fix : acceptanceTest error --- src/test/java/support/test/AcceptanceTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/support/test/AcceptanceTest.java b/src/test/java/support/test/AcceptanceTest.java index b88741e..64a00e1 100644 --- a/src/test/java/support/test/AcceptanceTest.java +++ b/src/test/java/support/test/AcceptanceTest.java @@ -12,7 +12,7 @@ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -public class AcceptanceTest { +public abstract class AcceptanceTest { private static final String DEFAULT_MANAGER_ACCOUNT_EMAIL = "admin@admin.com"; @Autowired From 2fb62948f52744628c94749ba3d21da3b5b24622 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8C=E1=85=A5=E1=86=BC=E1=84=86=E1=85=B5=E1=86=AB?= =?UTF-8?q?=E1=84=89=E1=85=A5=E1=86=A8?= Date: Fri, 3 May 2019 23:30:59 +0900 Subject: [PATCH 07/21] =?UTF-8?q?feature=20:=20=ED=8F=AC=ED=8A=B8=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20=EB=B0=8F=20=EB=B0=B0=ED=8F=AC=20=EC=9E=90?= =?UTF-8?q?=EB=8F=99=ED=99=94=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application-development.properties | 1 + src/main/resources/application-prod.properties | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/resources/application-development.properties b/src/main/resources/application-development.properties index 5833cf5..1ddc146 100644 --- a/src/main/resources/application-development.properties +++ b/src/main/resources/application-development.properties @@ -2,6 +2,7 @@ spring.datasource.url=jdbc:mysql://localhost:3306/springboot?useSSL=false&allowP spring.datasource.username=minseok spring.datasource.password=password +server.port=80 log4j.logger.org.hibernate.type=info spring.jpa.hibernate.ddl-auto=validate diff --git a/src/main/resources/application-prod.properties b/src/main/resources/application-prod.properties index 5833cf5..1ddc146 100644 --- a/src/main/resources/application-prod.properties +++ b/src/main/resources/application-prod.properties @@ -2,6 +2,7 @@ spring.datasource.url=jdbc:mysql://localhost:3306/springboot?useSSL=false&allowP spring.datasource.username=minseok spring.datasource.password=password +server.port=80 log4j.logger.org.hibernate.type=info spring.jpa.hibernate.ddl-auto=validate From 335dba371d9851098866ffe7cc39fccc6b6aa175 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8C=E1=85=A5=E1=86=BC=E1=84=86=E1=85=B5=E1=86=AB?= =?UTF-8?q?=E1=84=89=E1=85=A5=E1=86=A8?= Date: Fri, 3 May 2019 23:35:55 +0900 Subject: [PATCH 08/21] =?UTF-8?q?fix=20:=20=EB=B0=B0=ED=8F=AC=20script=20p?= =?UTF-8?q?ermission=20denied=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application-development.properties | 1 - src/main/resources/application-prod.properties | 1 - 2 files changed, 2 deletions(-) diff --git a/src/main/resources/application-development.properties b/src/main/resources/application-development.properties index 1ddc146..636b224 100644 --- a/src/main/resources/application-development.properties +++ b/src/main/resources/application-development.properties @@ -3,7 +3,6 @@ spring.datasource.username=minseok spring.datasource.password=password server.port=80 -log4j.logger.org.hibernate.type=info spring.jpa.hibernate.ddl-auto=validate diff --git a/src/main/resources/application-prod.properties b/src/main/resources/application-prod.properties index 1ddc146..636b224 100644 --- a/src/main/resources/application-prod.properties +++ b/src/main/resources/application-prod.properties @@ -3,7 +3,6 @@ spring.datasource.username=minseok spring.datasource.password=password server.port=80 -log4j.logger.org.hibernate.type=info spring.jpa.hibernate.ddl-auto=validate From b4e529854863596461520a051205507db7eee636 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8C=E1=85=A5=E1=86=BC=E1=84=86=E1=85=B5=E1=86=AB?= =?UTF-8?q?=E1=84=89=E1=85=A5=E1=86=A8?= Date: Fri, 3 May 2019 23:39:46 +0900 Subject: [PATCH 09/21] =?UTF-8?q?fix=20:=20=EB=B0=B0=ED=8F=AC=20script=20d?= =?UTF-8?q?irectory=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application-prod.properties | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/resources/application-prod.properties b/src/main/resources/application-prod.properties index 636b224..930fb0d 100644 --- a/src/main/resources/application-prod.properties +++ b/src/main/resources/application-prod.properties @@ -1,9 +1,8 @@ +server.port=80 + spring.datasource.url=jdbc:mysql://localhost:3306/springboot?useSSL=false&allowPublicKeyRetrieval=true spring.datasource.username=minseok spring.datasource.password=password - -server.port=80 - spring.jpa.hibernate.ddl-auto=validate logging.config=classpath:logback-${spring.profiles.active}.xml From 68344e98a883104e6462c80f2330b95989276e08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8C=E1=85=A5=E1=86=BC=E1=84=86=E1=85=B5=E1=86=AB?= =?UTF-8?q?=E1=84=89=E1=85=A5=E1=86=A8?= Date: Sat, 4 May 2019 00:02:57 +0900 Subject: [PATCH 10/21] =?UTF-8?q?feature=20:=20mysql=20init=EC=9D=84=20?= =?UTF-8?q?=EC=9C=84=ED=95=9C=20ddl-auto=20create=20=EC=B4=88=EA=B8=B0?= =?UTF-8?q?=EC=8B=A4=ED=96=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application-development.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/application-development.properties b/src/main/resources/application-development.properties index 636b224..f544dcb 100644 --- a/src/main/resources/application-development.properties +++ b/src/main/resources/application-development.properties @@ -4,6 +4,6 @@ spring.datasource.password=password server.port=80 -spring.jpa.hibernate.ddl-auto=validate +spring.jpa.hibernate.ddl-auto=create logging.config=classpath:logback-${spring.profiles.active}.xml From e6b5b248d7b15561795deb9e4ebe1ce51e74d12b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8C=E1=85=A5=E1=86=BC=E1=84=86=E1=85=B5=E1=86=AB?= =?UTF-8?q?=E1=84=89=E1=85=A5=E1=86=A8?= Date: Sat, 4 May 2019 00:07:02 +0900 Subject: [PATCH 11/21] =?UTF-8?q?feature=20:=20development=20ddl-auto=20va?= =?UTF-8?q?lidate=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../codesquad/intercepter/BasicAuthInterceptor.java | 12 ++++++------ src/main/java/support/domain/AbstractEntity.java | 6 ++++-- .../resources/application-development.properties | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main/java/codesquad/intercepter/BasicAuthInterceptor.java b/src/main/java/codesquad/intercepter/BasicAuthInterceptor.java index 338b746..8c2f80a 100644 --- a/src/main/java/codesquad/intercepter/BasicAuthInterceptor.java +++ b/src/main/java/codesquad/intercepter/BasicAuthInterceptor.java @@ -23,7 +23,7 @@ public class BasicAuthInterceptor extends HandlerInterceptorAdapter { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { String base64Credentials; - try{ + try { base64Credentials = getEncodedCredentials(request); String[] credentialValues = getDecodedCredentials(base64Credentials); String userId = credentialValues[0]; @@ -32,14 +32,14 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons log.debug("password : {}", password); login(request, userId, password); return true; - }catch (UnAuthenticationException e){ + } catch (UnAuthenticationException e) { return true; } } - public String getEncodedCredentials(HttpServletRequest request){ + public String getEncodedCredentials(HttpServletRequest request) { String authorization = request.getHeader("Authorization"); - if(authorization==null || !authorization.startsWith("Basic")){ + if (authorization == null || !authorization.startsWith("Basic")) { throw new UnAuthenticationException(); } return authorization.substring("Basic".length()).trim(); @@ -47,13 +47,13 @@ public String getEncodedCredentials(HttpServletRequest request){ public String[] getDecodedCredentials(String base64Credentials) { String credentials = new String(Base64.getDecoder().decode(base64Credentials), Charset.forName("UTF-8")); - return credentials.split(":",2); + return credentials.split(":", 2); } public void login(HttpServletRequest request, String userId, String password) { Account account = accountRepository.findByUserId(userId).orElseThrow(UnAuthenticationException::new); - if(account.matchPassword(password)){ + if (account.matchPassword(password)) { request.getSession().setAttribute(SessionUtils.USER_SESSION_KEY, account); } } diff --git a/src/main/java/support/domain/AbstractEntity.java b/src/main/java/support/domain/AbstractEntity.java index 0a8cead..e3922dc 100644 --- a/src/main/java/support/domain/AbstractEntity.java +++ b/src/main/java/support/domain/AbstractEntity.java @@ -36,8 +36,10 @@ public AbstractEntity(Long id) { @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; AbstractEntity that = (AbstractEntity) o; return Objects.equals(id, that.id); } diff --git a/src/main/resources/application-development.properties b/src/main/resources/application-development.properties index f544dcb..636b224 100644 --- a/src/main/resources/application-development.properties +++ b/src/main/resources/application-development.properties @@ -4,6 +4,6 @@ spring.datasource.password=password server.port=80 -spring.jpa.hibernate.ddl-auto=create +spring.jpa.hibernate.ddl-auto=validate logging.config=classpath:logback-${spring.profiles.active}.xml From 8299ea9efb615558f5e56d8ccb4daeefd2b0750f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8C=E1=85=A5=E1=86=BC=E1=84=86=E1=85=B5=E1=86=AB?= =?UTF-8?q?=E1=84=89=E1=85=A5=E1=86=A8?= Date: Sat, 4 May 2019 00:08:13 +0900 Subject: [PATCH 12/21] chore --- .../java/support/security/BasicAuthInterceptorTest.java | 4 ---- src/test/java/support/test/AcceptanceTest.java | 6 +++--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/test/java/support/security/BasicAuthInterceptorTest.java b/src/test/java/support/security/BasicAuthInterceptorTest.java index cc4e23c..e417bca 100644 --- a/src/test/java/support/security/BasicAuthInterceptorTest.java +++ b/src/test/java/support/security/BasicAuthInterceptorTest.java @@ -3,17 +3,13 @@ import codesquad.domain.Account; import codesquad.domain.AccountRepository; import codesquad.intercepter.BasicAuthInterceptor; -import codesquad.service.AccountService; import codesquad.util.SessionUtils; -import codesquad.web.dto.AccountLoginDTO; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import org.springframework.mock.web.MockHttpServletRequest; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; import java.util.Base64; import java.util.Optional; diff --git a/src/test/java/support/test/AcceptanceTest.java b/src/test/java/support/test/AcceptanceTest.java index 64a00e1..75e1991 100644 --- a/src/test/java/support/test/AcceptanceTest.java +++ b/src/test/java/support/test/AcceptanceTest.java @@ -21,11 +21,11 @@ public abstract class AcceptanceTest { @Autowired private AccountRepository accountRepository; - public TestRestTemplate template(){ + public TestRestTemplate template() { return testRestTemplate; } - public TestRestTemplate basicAuthTemplate(){ + public TestRestTemplate basicAuthTemplate() { return basicAuthTemplate(getDefaultManager()); } @@ -33,7 +33,7 @@ private Account getDefaultManager() { return accountRepository.findByUserId(DEFAULT_MANAGER_ACCOUNT_EMAIL).orElseThrow(UnAuthenticationException::new); } - public TestRestTemplate basicAuthTemplate(Account account){ + public TestRestTemplate basicAuthTemplate(Account account) { return testRestTemplate.withBasicAuth(account.getUserId(), account.getPassword()); } From 144bec14ca1297bb22a99ff96170dd55194a1038 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8C=E1=85=A5=E1=86=BC=E1=84=86=E1=85=B5=E1=86=AB?= =?UTF-8?q?=E1=84=89=E1=85=A5=E1=86=A8?= Date: Wed, 22 May 2019 16:30:33 +0900 Subject: [PATCH 13/21] =?UTF-8?q?feature=20:=20=EC=8A=AC=EB=9E=99=20noti?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application-local.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/application-local.properties b/src/main/resources/application-local.properties index f17ee14..2d22f6b 100755 --- a/src/main/resources/application-local.properties +++ b/src/main/resources/application-local.properties @@ -1,6 +1,6 @@ spring.jpa.hibernate.ddl-auto=create -spring.jpa.show-sql=true +spring.jpa.show-sql=true spring.jpa.properties.hibernate.format_sql=true logging.level.org.hibernate.type.descriptor.sql=trace From 84d7131be19f0ea8c230f132ce32870dd5a17bd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8C=E1=85=A5=E1=86=BC=E1=84=86=E1=85=B5=E1=86=AB?= =?UTF-8?q?=E1=84=89=E1=85=A5=E1=86=A8?= Date: Wed, 22 May 2019 16:48:36 +0900 Subject: [PATCH 14/21] =?UTF-8?q?feature=20:=20=EC=9E=90=EB=8F=99=EB=B0=B0?= =?UTF-8?q?=ED=8F=AC=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/codesquad/web/ApiMemberController.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/codesquad/web/ApiMemberController.java b/src/main/java/codesquad/web/ApiMemberController.java index 71ed0bb..b7c7c12 100644 --- a/src/main/java/codesquad/web/ApiMemberController.java +++ b/src/main/java/codesquad/web/ApiMemberController.java @@ -31,6 +31,7 @@ public class ApiMemberController { @PostMapping("") public ResponseEntity createMember(@Valid @RequestBody AccountRegistrationDTO accountRegistrationDTO) { accountService.save(accountRegistrationDTO); + return makeDefaultResponseEntity("/login", HttpStatus.CREATED); } From cb370cc1dddbce43f7317edeac2411f79215288e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8C=E1=85=A5=E1=86=BC=E1=84=86=E1=85=B5=E1=86=AB?= =?UTF-8?q?=E1=84=89=E1=85=A5=E1=86=A8?= Date: Wed, 22 May 2019 17:00:41 +0900 Subject: [PATCH 15/21] =?UTF-8?q?fix=20:=20=EB=B0=B0=ED=8F=AC=20=EC=8A=A4?= =?UTF-8?q?=ED=81=AC=EB=A6=BD=ED=8A=B8=20=EC=88=98=EC=A0=95=20/=20?= =?UTF-8?q?=EA=B2=BD=EB=A1=9C=EB=AC=B8=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/codesquad/web/ApiMemberController.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/codesquad/web/ApiMemberController.java b/src/main/java/codesquad/web/ApiMemberController.java index b7c7c12..71ed0bb 100644 --- a/src/main/java/codesquad/web/ApiMemberController.java +++ b/src/main/java/codesquad/web/ApiMemberController.java @@ -31,7 +31,6 @@ public class ApiMemberController { @PostMapping("") public ResponseEntity createMember(@Valid @RequestBody AccountRegistrationDTO accountRegistrationDTO) { accountService.save(accountRegistrationDTO); - return makeDefaultResponseEntity("/login", HttpStatus.CREATED); } From 4945bc7eb3ef0aeb377b3fa64a22bdc721757dfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8C=E1=85=A5=E1=86=BC=E1=84=86=E1=85=B5=E1=86=AB?= =?UTF-8?q?=E1=84=89=E1=85=A5=E1=86=A8?= Date: Wed, 22 May 2019 17:07:58 +0900 Subject: [PATCH 16/21] =?UTF-8?q?fix=20:=20=EB=B0=B0=ED=8F=AC=20=EC=8A=A4?= =?UTF-8?q?=ED=81=AC=EB=A6=BD=ED=8A=B8=20=EC=88=98=EC=A0=95=20/=20backgrou?= =?UTF-8?q?nd=20=EC=8B=A4=ED=96=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/codesquad/web/ApiMemberController.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/codesquad/web/ApiMemberController.java b/src/main/java/codesquad/web/ApiMemberController.java index 71ed0bb..ad38590 100644 --- a/src/main/java/codesquad/web/ApiMemberController.java +++ b/src/main/java/codesquad/web/ApiMemberController.java @@ -37,6 +37,7 @@ public ResponseEntity createMember(@Valid @RequestBody AccountRegistration @PostMapping("/login") public ResponseEntity login(HttpSession session, @Valid @RequestBody AccountLoginDTO accountLoginDTO) { session.setAttribute(SessionUtils.USER_SESSION_KEY, accountService.findAccount(accountLoginDTO)); + return makeDefaultResponseEntity("/", HttpStatus.OK); } From 66425d92a8119f1699061212872b6d3a1fd6e5a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8C=E1=85=A5=E1=86=BC=E1=84=86=E1=85=B5=E1=86=AB?= =?UTF-8?q?=E1=84=89=E1=85=A5=E1=86=A8?= Date: Wed, 22 May 2019 17:15:08 +0900 Subject: [PATCH 17/21] =?UTF-8?q?fix=20:=20slack=20noti=20=EC=A3=BC?= =?UTF-8?q?=EC=86=8C=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/codesquad/web/ApiMemberController.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/codesquad/web/ApiMemberController.java b/src/main/java/codesquad/web/ApiMemberController.java index ad38590..71ed0bb 100644 --- a/src/main/java/codesquad/web/ApiMemberController.java +++ b/src/main/java/codesquad/web/ApiMemberController.java @@ -37,7 +37,6 @@ public ResponseEntity createMember(@Valid @RequestBody AccountRegistration @PostMapping("/login") public ResponseEntity login(HttpSession session, @Valid @RequestBody AccountLoginDTO accountLoginDTO) { session.setAttribute(SessionUtils.USER_SESSION_KEY, accountService.findAccount(accountLoginDTO)); - return makeDefaultResponseEntity("/", HttpStatus.OK); } From 555f1ee237dfd39acf8aa96abd849d46d1bdd044 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8C=E1=85=A5=E1=86=BC=E1=84=86=E1=85=B5=E1=86=AB?= =?UTF-8?q?=E1=84=89=E1=85=A5=E1=86=A8?= Date: Wed, 22 May 2019 17:35:14 +0900 Subject: [PATCH 18/21] =?UTF-8?q?fix=20:=20=EB=B0=B0=ED=8F=AC=20=EC=8A=A4?= =?UTF-8?q?=ED=81=AC=EB=A6=BD=ED=8A=B8=20process=20=EC=A4=91=EB=B3=B5=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/codesquad/web/ApiMemberController.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/codesquad/web/ApiMemberController.java b/src/main/java/codesquad/web/ApiMemberController.java index 71ed0bb..b7c7c12 100644 --- a/src/main/java/codesquad/web/ApiMemberController.java +++ b/src/main/java/codesquad/web/ApiMemberController.java @@ -31,6 +31,7 @@ public class ApiMemberController { @PostMapping("") public ResponseEntity createMember(@Valid @RequestBody AccountRegistrationDTO accountRegistrationDTO) { accountService.save(accountRegistrationDTO); + return makeDefaultResponseEntity("/login", HttpStatus.CREATED); } From a5dfd73d7bfb4f24766217d17c10f5c09f948a36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8C=E1=85=A5=E1=86=BC=E1=84=86=E1=85=B5=E1=86=AB?= =?UTF-8?q?=E1=84=89=E1=85=A5=E1=86=A8?= Date: Fri, 24 May 2019 23:36:08 +0900 Subject: [PATCH 19/21] =?UTF-8?q?fix=20:=20jar=ED=8C=8C=EC=9D=BC=20name=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e068a77..5d3d2e8 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ 1.0.0 jar - baeminchan + webapi 배민찬 서비스 From 49ee8e436ed27e63820c92c0754c987bba64fdd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8C=E1=85=A5=E1=86=BC=E1=84=86=E1=85=B5=E1=86=AB?= =?UTF-8?q?=E1=84=89=E1=85=A5=E1=86=A8?= Date: Fri, 24 May 2019 23:43:29 +0900 Subject: [PATCH 20/21] =?UTF-8?q?fix=20:=20jar=ED=8C=8C=EC=9D=BC=20name=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 5d3d2e8..b659ab8 100644 --- a/pom.xml +++ b/pom.xml @@ -4,11 +4,11 @@ 4.0.0 kr.codesquad - baeminchan + webApi 1.0.0 jar - webapi + webservice 배민찬 서비스 From 79a2c95ac4253e1afb88551fb443d75578f4baaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8C=E1=85=A5=E1=86=BC=E1=84=86=E1=85=B5=E1=86=AB?= =?UTF-8?q?=E1=84=89=E1=85=A5=E1=86=A8?= Date: Fri, 24 May 2019 23:50:53 +0900 Subject: [PATCH 21/21] =?UTF-8?q?fix=20:=20jar=ED=8C=8C=EC=9D=BC=20name=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b659ab8..8e3bbfd 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ 1.0.0 jar - webservice + webApi 배민찬 서비스