Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
JeongSangByuk committed Sep 7, 2024
2 parents c459167 + 63536e9 commit b332466
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 53 deletions.
7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ dependencies {
annotationProcessor "jakarta.annotation:jakarta.annotation-api"
annotationProcessor "jakarta.persistence:jakarta.persistence-api"

implementation 'net.logstash.logback:logstash-logback-encoder:7.4'

//s3
implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'

Expand Down Expand Up @@ -114,7 +116,7 @@ bootJar {
}

openapi3 {
server = "https://dev.bbogak.com"
server = System.getenv('API_SERVER_URL') ?: "http://localhost:8080"
title = "뽀각 API 문서"
description = "뽀각 API 문서입니다."
version = "0.0.1"
Expand All @@ -123,5 +125,4 @@ openapi3 {

// /static/docs/open-api-3.0.1.json 생성 → jar 파일만 배포할 예정이기에 build 에 출력
outputDirectory = 'build/resources/main/static/docs'
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ public interface RecruitRepository extends JpaRepository<Recruit, Long> {

List<Recruit> findAllByUserIdAndSeason(Long userId, Season season);

List<Recruit> findTop5ByUserIdOrderByCreatedDateAsc(Long userId);
List<Recruit> findTop5ByUserIdOrderByCreatedDateDesc(Long userId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public List<RecruitGetResponse> getRecruitListBySeason(User user, String seasonN
}

public List<RecruitGetTitleListResponse> getRecruitRecent5TitleList(User user) {
return recruitRepository.findTop5ByUserIdOrderByCreatedDateAsc(user.getId())
return recruitRepository.findTop5ByUserIdOrderByCreatedDateDesc(user.getId())
.stream()
.map(RecruitGetTitleListResponse::from)
.toList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public enum ErrorCode {
CARD_TAG_NOT_FOUND(HttpStatus.NOT_FOUND, "해당 카드와 태그 매핑을 찾을 수 없습니다"),

//CardMemo
CARD_MEMO_NOT_FOUND(HttpStatus.NOT_FOUND, "해당 카드를 찾을 수 없습니다");
CARD_MEMO_NOT_FOUND(HttpStatus.NOT_FOUND, "해당 카드 메모를 찾을 수 없습니다");


private final HttpStatus status;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.server.bbo_gak.domain.auth.controller;

import static com.server.bbo_gak.global.security.jwt.service.JwtTokenService.TOKEN_ROLE_NAME;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static com.epages.restdocs.apispec.MockMvcRestDocumentationWrapper.document;
import static com.epages.restdocs.apispec.ResourceDocumentation.parameterWithName;
import static com.epages.restdocs.apispec.ResourceDocumentation.resource;
import static com.server.bbo_gak.global.security.jwt.service.JwtTokenService.TOKEN_ROLE_NAME;
import static org.hamcrest.Matchers.matchesPattern;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.when;
import static org.springframework.restdocs.headers.HeaderDocumentation.headerWithName;
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post;
Expand All @@ -20,10 +20,10 @@

import com.epages.restdocs.apispec.ResourceSnippetParameters;
import com.server.bbo_gak.domain.auth.dto.request.LoginRequest;
import com.server.bbo_gak.domain.auth.dto.request.RefreshTokenRequest;
import com.server.bbo_gak.domain.auth.dto.response.oauth.OauthUserInfoResponse;
import com.server.bbo_gak.domain.auth.service.oauth.GoogleService;
import com.server.bbo_gak.domain.user.entity.OauthProvider;
import com.server.bbo_gak.domain.auth.dto.request.RefreshTokenRequest;
import com.server.bbo_gak.domain.user.entity.UserRole;
import com.server.bbo_gak.global.AbstractRestDocsTests;
import com.server.bbo_gak.global.RestDocsFactory;
Expand All @@ -42,8 +42,8 @@
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.test.annotation.Rollback;
import org.springframework.http.MediaType;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.jdbc.Sql;
import org.springframework.transaction.annotation.Transactional;
Expand Down Expand Up @@ -89,6 +89,7 @@ void setUp() {
.signWith(Keys.hmacShaKeyFor(jwtRTSecret.getBytes()), SignatureAlgorithm.HS256)
.setIssuer(issuer)
.compact();

}

@Nested
Expand All @@ -101,53 +102,53 @@ class 소셜_로그인 {
OauthProvider provider = OauthProvider.GOOGLE;
//구글 서비스 모킹
OauthUserInfoResponse mockOauthUserInfoResponse = OauthUserInfoResponse.builder()
.oauthId("oauthId")
.email("email")
.name("name")
.provider(provider)
.build();
.oauthId("oauthId")
.email("email")
.name("name")
.provider(provider)
.build();
when(googleService.getOauthUserInfo(socialAccessToken)).thenReturn(mockOauthUserInfoResponse);

//when
mockMvc.perform(post("/api/v1/users/social-login")
.header("SOCIAL-AUTH-TOKEN", socialAccessToken)
.queryParam("provider", provider.name())
.contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON))

//then
// Verifying HTTP request matching
.andExpect(status().isOk())
// 헤더 검증 - requestBody의 content-type
.andExpect(
header().string(HttpHeaders.CONTENT_TYPE, matchesPattern("application/json(;charset=UTF-8)?")))
// Verifying output serialization
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("$.accessToken").isNotEmpty()) // accessToken 존재 검증
.andExpect(jsonPath("$.refreshToken").isNotEmpty()) // refreshToken 존재 검증

// RestDocs 문서
.andDo(document("[소셜 로그인] 성공",
preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()),
resource(
ResourceSnippetParameters.builder()
.tags("auth") // API 문서의 태그
.description("소셜로그인 - jwt 토큰 생성") // API 문서의 설명
.requestHeaders(
headerWithName("SOCIAL-AUTH-TOKEN").description(
"소셜 엑세스 토큰")
)
.queryParameters(
parameterWithName("provider").description("OAuth provider(ex) GOOGLE)")
)
.responseFields( // 응답 필드
fieldWithPath("accessToken").description("accessToken"),
fieldWithPath("refreshToken").description("refreshToken"),
fieldWithPath("isFirstLogin").description("isFirstLogin")
)
.build()
)));
.header("SOCIAL-AUTH-TOKEN", socialAccessToken)
.queryParam("provider", provider.name())
.contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON))

//then
// Verifying HTTP request matching
.andExpect(status().isOk())
// 헤더 검증 - requestBody의 content-type
.andExpect(
header().string(HttpHeaders.CONTENT_TYPE, matchesPattern("application/json(;charset=UTF-8)?")))
// Verifying output serialization
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("$.accessToken").isNotEmpty()) // accessToken 존재 검증
.andExpect(jsonPath("$.refreshToken").isNotEmpty()) // refreshToken 존재 검증

// RestDocs 문서
.andDo(document("[소셜 로그인] 성공",
preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()),
resource(
ResourceSnippetParameters.builder()
.tags("auth") // API 문서의 태그
.description("소셜로그인 - jwt 토큰 생성") // API 문서의 설명
.requestHeaders(
headerWithName("SOCIAL-AUTH-TOKEN").description(
"소셜 엑세스 토큰")
)
.queryParameters(
parameterWithName("provider").description("OAuth provider(ex) GOOGLE)")
)
.responseFields( // 응답 필드
fieldWithPath("accessToken").description("accessToken"),
fieldWithPath("refreshToken").description("refreshToken"),
fieldWithPath("isFirstLogin").description("isFirstLogin")
)
.build()
)));


}
Expand Down

0 comments on commit b332466

Please sign in to comment.