diff --git a/.travis.yml b/.travis.yml index 31fdc6a..7d6317d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,19 +15,19 @@ cache: script: "./gradlew clean build" before_deploy: - - mkdir -p before-deploy # zip에 포함시킬 파일들을 담을 디렉토리 생성 + - mkdir -p before-deploy #zip에 포함시킬 파일들을 담을 디렉토리 생성 - cp scripts/*.sh before-deploy/ - cp appspec.yml before-deploy/ - cp build/libs/*.jar before-deploy/ - - cd before-deploy && zip -r before-deploy * # before-deploy로 이동후 전체 압축 - - cd ../ && mkdir -p deploy # 상위 디렉토리로 이동후 deploy 디렉토리 생성 - - mv before-deploy/before-deploy.zip deploy/freelec-springboot2-webservice.zip # deploy로 zip파일 이동 + - cd before-deploy && zip -r before-deploy * #before-deploy로 이동 후 전체압축 + - cd ../ && mkdir -p deploy + - mv before-deploy/before-deploy.zip deploy/freelec-springboot2-webservice.zip deploy: - provider: s3 access_key_id: $AWS_ACCESS_KEY # Travis repo settings에 설정된 값 secret_access_key: $AWS_SECRET_KEY # Travis repo settings에 설정된 값 - bucket: freelec-springboot-build # S3 버킷 + bucket: freelec-springboot-builddd # S3 버킷 region: ap-northeast-2 skip_cleanup: true acl: private # zip 파일 접근을 private으로 @@ -37,7 +37,7 @@ deploy: - provider: codedeploy access_key_id: $AWS_ACCESS_KEY # Travis repo settings에 설정된 값 secret_access_key: $AWS_SECRET_KEY # Travis repo settings에 설정된 값 - bucket: freelec-springboot-build # S3 버킷 + bucket: freelec-springboot-builddd # S3 버킷 key: freelec-springboot2-webservice.zip # 빌드 파일을 압축해서 전달 bundle_type: zip application: freelec-springboot2-webservice # 웹 콘솔에서 등록한 CodeDeploy 어플리케이션 @@ -49,4 +49,4 @@ deploy: notifications: email: recipients: - - jojoldu@gmail.com \ No newline at end of file + - kbh11051@gmail.com \ No newline at end of file diff --git a/appspec.yml b/appspec.yml index 59260b1..0bfea24 100644 --- a/appspec.yml +++ b/appspec.yml @@ -2,7 +2,7 @@ version: 0.0 os: linux files: - source: / - destination: /home/ec2-user/app/step3/zip/ + destination: /home/ec2-user/app/step2/zip/ overwrite: yes permissions: @@ -12,15 +12,7 @@ permissions: group: ec2-user hooks: - AfterInstall: - - location: stop.sh # 엔진엑스와 연결되어 있지 않은 스프링 부트를 종료합니다. - timeout: 60 - runas: ec2-user - ApplicationStart: - - location: start.sh # 엔진엑스와 연결되어 있지 않은 Port로 새 버전의 스프링 부트를 시작합니다. - timeout: 60 - runas: ec2-user - ValidateService: - - location: health.sh # 새 스프링 부트가 정상적으로 실행됐는지 확인 합니다. - timeout: 60 - runas: ec2-user + ApplicationStart: + - location : deploy.sh + timeout : 60 + runas: ec2-user diff --git a/build.gradle b/build.gradle index 682b4a8..388d031 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,7 @@ apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management' group 'com.jojoldu.book' -version '1.0.4-SNAPSHOT-'+new Date().format("yyyyMMddHHmmss") +version '1.0.5-SNAPSHOT-'+new Date().format("yyyyMMddHHmmss") sourceCompatibility = 1.8 repositories { @@ -31,6 +31,7 @@ dependencies { compile('org.springframework.boot:spring-boot-starter-data-jpa') compile('org.springframework.boot:spring-boot-starter-mustache') compile('com.h2database:h2') + compile('org.mariadb.jdbc:mariadb-java-client') compile('org.springframework.boot:spring-boot-starter-oauth2-client') compile('org.springframework.session:spring-session-jdbc') diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..2427fd0 --- /dev/null +++ b/gradle.properties @@ -0,0 +1 @@ +org.gradle.jvmargs=-Xmx1536m \ No newline at end of file diff --git a/src/main/java/com/jojoldu/book/springboot/config/auth/LoginUser.java b/src/main/java/com/jojoldu/book/springboot/config/auth/LoginUser.java index b12dc56..10e9277 100644 --- a/src/main/java/com/jojoldu/book/springboot/config/auth/LoginUser.java +++ b/src/main/java/com/jojoldu/book/springboot/config/auth/LoginUser.java @@ -4,7 +4,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; - +//login annotation @Target(ElementType.PARAMETER) @Retention(RetentionPolicy.RUNTIME) public @interface LoginUser { diff --git a/src/main/resources/application-oauth.properties b/src/main/resources/application-oauth.properties index ca6e250..58f593b 100644 --- a/src/main/resources/application-oauth.properties +++ b/src/main/resources/application-oauth.properties @@ -1,10 +1,10 @@ -spring.security.oauth2.client.registration.google.client-id=구글클라이언트ID -spring.security.oauth2.client.registration.google.client-secret=구글클라이언트시크릿 +spring.security.oauth2.client.registration.google.client-id=282098600293-elskch6lntksqvq3a73cde38ss9g9bno.apps.googleusercontent.com +spring.security.oauth2.client.registration.google.client-secret=H9jjsbkYA3To0WamEGBrj_MR spring.security.oauth2.client.registration.google.scope=profile,email # registration -spring.security.oauth2.client.registration.naver.client-id=네이버클라이언트ID -spring.security.oauth2.client.registration.naver.client-secret=네이버클라이언트시크릿 +spring.security.oauth2.client.registration.naver.client-id=2tcXMT6_qOGw3PxjYM4p +spring.security.oauth2.client.registration.naver.client-secret=ld0WuBgvCb spring.security.oauth2.client.registration.naver.redirect-uri={baseUrl}/{action}/oauth2/code/{registrationId} spring.security.oauth2.client.registration.naver.authorization-grant-type=authorization_code spring.security.oauth2.client.registration.naver.scope=name,email,profile_image @@ -16,3 +16,5 @@ spring.security.oauth2.client.provider.naver.token-uri=https://nid.naver.com/oau spring.security.oauth2.client.provider.naver.user-info-uri=https://openapi.naver.com/v1/nid/me spring.security.oauth2.client.provider.naver.user-name-attribute=response + + diff --git a/src/main/resources/application-real-db.properties b/src/main/resources/application-real-db.properties deleted file mode 100644 index 85449a4..0000000 --- a/src/main/resources/application-real-db.properties +++ /dev/null @@ -1,6 +0,0 @@ -spring.jpa.hibernate.ddl-auto=none - -spring.datasource.url=jdbc:mariadb://rds주소:포트명(기본은 3306)/database명 -spring.datasource.username=db계정 -spring.datasource.password=db계정 비밀번호 -spring.datasource.driver-class-name=org.mariadb.jdbc.Driver \ No newline at end of file diff --git a/src/main/resources/application-real.properties b/src/main/resources/application-real.properties index bec6465..89e6000 100644 --- a/src/main/resources/application-real.properties +++ b/src/main/resources/application-real.properties @@ -1,3 +1,5 @@ spring.profiles.include=oauth,real-db +spring.jpa.show_sql=true spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect -spring.session.store-type=jdbc +spring.h2.console.enabled=true +spring.session.store-type=jdbc \ No newline at end of file diff --git a/src/main/resources/application-real1.properties b/src/main/resources/application-real1.properties deleted file mode 100644 index 04cef5a..0000000 --- a/src/main/resources/application-real1.properties +++ /dev/null @@ -1,4 +0,0 @@ -server.port=8081 -spring.profiles.include=oauth,real-db -spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect -spring.session.store-type=jdbc \ No newline at end of file diff --git a/src/main/resources/application-real2.properties b/src/main/resources/application-real2.properties deleted file mode 100644 index 39aaa94..0000000 --- a/src/main/resources/application-real2.properties +++ /dev/null @@ -1,4 +0,0 @@ -server.port=8082 -spring.profiles.include=oauth,real-db -spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect -spring.session.store-type=jdbc \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 11e4e61..c22daf5 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,4 +1,4 @@ -spring.profiles.include=real-oauth +spring.profiles.include=oauth spring.jpa.show_sql=true spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect spring.h2.console.enabled=true diff --git a/src/main/resources/templates/index.mustache b/src/main/resources/templates/index.mustache index bb4975d..ea829d2 100644 --- a/src/main/resources/templates/index.mustache +++ b/src/main/resources/templates/index.mustache @@ -1,6 +1,6 @@ {{>layout/header}} -

스프링부트로 시작하는 웹 서비스 Ver.2

+

스프링부트로 시작하는 웹 서비스˚

diff --git a/src/test/java/com/jojoldu/book/springboot/domain/posts/PostsRepositoryTest.java b/src/test/java/com/jojoldu/book/springboot/domain/posts/PostsRepositoryTest.java index 92d3da2..baa205b 100644 --- a/src/test/java/com/jojoldu/book/springboot/domain/posts/PostsRepositoryTest.java +++ b/src/test/java/com/jojoldu/book/springboot/domain/posts/PostsRepositoryTest.java @@ -25,7 +25,7 @@ public void cleanup() { } @Test - public void 게시글저장_불러오기() { + public void 게시글저장_불러오기2() { //given String title = "테스트 게시글"; String content = "테스트 본문"; diff --git a/src/test/java/com/jojoldu/book/springboot/web/IndexControllerTest.java b/src/test/java/com/jojoldu/book/springboot/web/IndexControllerTest.java index cc58c3a..4812abe 100644 --- a/src/test/java/com/jojoldu/book/springboot/web/IndexControllerTest.java +++ b/src/test/java/com/jojoldu/book/springboot/web/IndexControllerTest.java @@ -18,7 +18,7 @@ public class IndexControllerTest { private TestRestTemplate restTemplate; @Test - public void 메인페이지_로딩() { + public void 메인페이지_로딩테스트12() { //when String body = this.restTemplate.getForObject("/", String.class); diff --git a/src/test/java/com/jojoldu/book/springboot/web/ProfileControllerTest.java b/src/test/java/com/jojoldu/book/springboot/web/ProfileControllerTest.java deleted file mode 100644 index 317943f..0000000 --- a/src/test/java/com/jojoldu/book/springboot/web/ProfileControllerTest.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.jojoldu.book.springboot.web; - -import org.junit.Test; -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.boot.web.server.LocalServerPort; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.test.context.junit4.SpringRunner; - -import static org.assertj.core.api.Assertions.assertThat; - -@RunWith(SpringRunner.class) -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -public class ProfileControllerTest { - - @LocalServerPort - private int port; - - @Autowired - private TestRestTemplate restTemplate; - - @Test - public void profile은_인증없이_호출된다() throws Exception { - String expected = "default"; - - ResponseEntity response = restTemplate.getForEntity("/profile", String.class); - assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); - assertThat(response.getBody()).isEqualTo(expected); - } -} diff --git a/src/test/java/com/jojoldu/book/springboot/web/ProfileControllerUnitTest.java b/src/test/java/com/jojoldu/book/springboot/web/ProfileControllerUnitTest.java deleted file mode 100644 index 1d0c517..0000000 --- a/src/test/java/com/jojoldu/book/springboot/web/ProfileControllerUnitTest.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.jojoldu.book.springboot.web; - -import org.junit.Test; -import org.springframework.mock.env.MockEnvironment; - -import static org.assertj.core.api.Assertions.assertThat; - -public class ProfileControllerUnitTest { - - @Test - public void real_profile이_조회된다() { - //given - String expectedProfile = "real"; - MockEnvironment env = new MockEnvironment(); - env.addActiveProfile(expectedProfile); - env.addActiveProfile("oauth"); - env.addActiveProfile("real-db"); - - ProfileController controller = new ProfileController(env); - - //when - String profile = controller.profile(); - - //then - assertThat(profile).isEqualTo(expectedProfile); - } - - @Test - public void real_profile이_없으면_첫번째가_조회된다() { - //given - String expectedProfile = "oauth"; - MockEnvironment env = new MockEnvironment(); - - env.addActiveProfile(expectedProfile); - env.addActiveProfile("real-db"); - - ProfileController controller = new ProfileController(env); - - //when - String profile = controller.profile(); - - //then - assertThat(profile).isEqualTo(expectedProfile); - } - - @Test - public void active_profile이_없으면_default가_조회된다() { - //given - String expectedProfile = "default"; - MockEnvironment env = new MockEnvironment(); - ProfileController controller = new ProfileController(env); - - //when - String profile = controller.profile(); - - //then - assertThat(profile).isEqualTo(expectedProfile); - } -} diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties index 6c215a7..4e8155a 100644 --- a/src/test/resources/application.properties +++ b/src/test/resources/application.properties @@ -3,8 +3,8 @@ spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialec spring.h2.console.enabled=true spring.session.store-type=jdbc -# Test OAuth +# Test OAuth spring.security.oauth2.client.registration.google.client-id=test spring.security.oauth2.client.registration.google.client-secret=test spring.security.oauth2.client.registration.google.scope=profile,email \ No newline at end of file