Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BE] DB 날짜 데이터 kst로 출력되도록 변경하기 (#125) #128

Merged
merged 4 commits into from
Jul 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@

@Configuration
@EnableJpaAuditing
public class EnableJpaAuditingConfiguration {
public class JpaAuditingConfiguration {

}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.darass.darass.common.domain;

import javax.persistence.Column;
import lombok.Getter;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
Expand All @@ -15,9 +16,11 @@
public abstract class BaseTimeEntity {

@CreatedDate
@Column(columnDefinition = "TIMESTAMP")
private LocalDateTime createdDate;

@LastModifiedDate
@Column(columnDefinition = "TIMESTAMP")
private LocalDateTime modifiedDate;

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static org.assertj.core.api.Assertions.assertThat;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.mock.web.MockHttpServletRequest;
Expand All @@ -10,13 +11,21 @@
class AuthorizationExtractorTest {

private final MockHttpServletRequest mockHttpServletRequest = new MockHttpServletRequest();
private final String tokenType = "Bearer ";
private final String basicAuthType = "Basic ";
private final String bearerAuthType = "Bearer ";
private final String mutualAuthType = "Mutual ";
private final String accessToken = "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIiwiaWF0IjoxNjI2NTI2MzI3LCJleHAiOjE2MjY1MzE1MTF9.ByMJIr0G2gLcQs_7N6lLpEWAqWXq4CYdEe-QUfMjWI0";

@BeforeEach
void setUp(){
mockHttpServletRequest.addHeader("authorization", mutualAuthType + accessToken);
mockHttpServletRequest.addHeader("authorization", basicAuthType + accessToken);
}

@DisplayName("extract 메서드는 Bearer 타입 토큰 정보가 담긴 Authorization 헤더를 가지는 httpServletRequest가 주어진다면, 엑세스 토큰을 파싱헤서 반환한다.")
@Test
void extract_success1() {
mockHttpServletRequest.addHeader("Authorization", tokenType + accessToken);
mockHttpServletRequest.addHeader("authorization", bearerAuthType + accessToken);
AuthorizationExtractor authorizationExtractor = new AuthorizationExtractor();

assertThat(authorizationExtractor.extract(mockHttpServletRequest)).isEqualTo(accessToken);
Expand All @@ -25,7 +34,7 @@ void extract_success1() {
@DisplayName("extract 메서드는 엑세스 토큰 뒤에 추가 정보가 콤마를 기준으로 붙어 있는 Authorization 헤더를 가지는 httpServletRequest가 주어진다면, 엑세스 토큰을 파싱헤서 반환한다.")
@Test
void extract_success2() {
mockHttpServletRequest.addHeader("Authorization", tokenType + accessToken + ", Basic YXNkZnNhZGZzYWRmOlZLdDVOMVhk");
mockHttpServletRequest.addHeader("authorization", bearerAuthType + accessToken + ", Basic YXNkZnNhZGZzYWRmOlZLdDVOMVhk");
AuthorizationExtractor authorizationExtractor = new AuthorizationExtractor();

assertThat(authorizationExtractor.extract(mockHttpServletRequest)).isEqualTo(accessToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
import static org.assertj.core.api.Assertions.assertThat;

import com.darass.darass.project.domain.Project;
import com.darass.darass.project.domain.RandomSecretKeyFactory;
import com.darass.darass.project.service.CustomSecretKeyFactory;
import java.util.ArrayList;
import java.util.List;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

@DisplayName("")
@DisplayName("Comments 클래스")
class CommentsTest {

private final List<Comment> commentList = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import com.darass.darass.user.domain.OAuthPlatform;
import com.darass.darass.user.domain.SocialLoginUser;
import com.darass.darass.user.repository.SocialLoginUserRepository;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -28,11 +31,11 @@ public void saveCreatedDateAndModifiedDate() {
//given
LocalDateTime now = LocalDateTime.now();
socialLoginUserRepository.save(SocialLoginUser.builder()
.nickName("병욱")
.email("[email protected]")
.oauthId("241323123")
.oauthPlatform(OAuthPlatform.KAKAO)
.build());
.nickName("병욱")
.email("[email protected]")
.oauthId("241323123")
.oauthPlatform(OAuthPlatform.KAKAO)
.build());

//when
List<SocialLoginUser> socialLoginUsers = socialLoginUserRepository.findAll();
Expand Down