Skip to content

Commit

Permalink
Merge pull request #188 from SWM-GSM/develop
Browse files Browse the repository at this point in the history
deploy: develop → main으로 브랜치 업데이트
  • Loading branch information
leeeeeyeon authored Sep 8, 2023
2 parents 4111cac + 1e34277 commit 584ac1c
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 29 deletions.
15 changes: 15 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,19 @@ jacocoTestReport {
html.enabled true
html.destination file("${buildDir}/jacoco/index.html")
}

def Qdomains = []
for(qPattern in "**/QA" .. "**/QZ"){
Qdomains.add(qPattern+"*")
}

afterEvaluate {
classDirectories.setFrom(
files(classDirectories.files.collect {
fileTree(dir: it, exclude: [
'**/dummy/**/*.*'
] + Qdomains)
})
)
}
}
2 changes: 1 addition & 1 deletion security
11 changes: 5 additions & 6 deletions src/main/java/com/gsm/blabla/auth/application/AuthService.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public JwtDto signup(String providerAuthorization, MemberRequestDto memberReques
case "APPLE" -> {
AppleTokenDto appleTokenDto = getAppleToken(providerAuthorization);
AppleAccountDto appleAccountDto = getAppleAccount(appleTokenDto.getIdToken());
if (appleAccountRepository.findById(appleTokenDto.getIdToken()).isPresent()) {
if (appleAccountRepository.findById(appleAccountDto.getSub()).isPresent()) {
throw new GeneralException(Code.ALREADY_REGISTERED, "이미 가입된 애플 계정입니다.");
}

Expand All @@ -133,7 +133,7 @@ public JwtDto signup(String providerAuthorization, MemberRequestDto memberReques
if (size != 0 && (size < 3 || size > 10)) {
throw new GeneralException(Code.VALIDATION_ERROR, "관심사는 0개 또는 3개 이상 10개 이하로 설정해야 합니다.");
}

// 키워드
for (Keyword keyword : memberRequestDto.getKeywords()) {
memberKeywordRepository.save(MemberKeyword.builder()
Expand Down Expand Up @@ -237,7 +237,7 @@ private AppleAccountDto getAppleAccount(String identityToken) {
ApplePublicKeyDto applePublicKey = new RestTemplate().exchange(
"https://appleid.apple.com/auth/keys",
HttpMethod.GET,
null,
new HttpEntity<>(null, null),
ApplePublicKeyDto.class
).getBody();

Expand Down Expand Up @@ -278,9 +278,9 @@ private AppleTokenDto getAppleToken(String appleAuthorizationCode) {
appleAuthorizationCode = appleAuthorizationCode.replace("Bearer ", "");

HttpHeaders headers = new HttpHeaders();
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();

headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);

MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
params.add("client_id", appleClientId);
params.add("client_secret", getAppleClientSecret());
params.add("code", appleAuthorizationCode);
Expand All @@ -307,7 +307,6 @@ private String getAppleClientSecret() throws IOException {
.setExpiration(expirationDate)
.setAudience("https://appleid.apple.com")
.setSubject(appleClientId)
.setSubject(appleClientId)
.signWith(SignatureAlgorithm.ES256, getApplePrivateKey())
.compact();
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/gsm/blabla/crew/domain/CrewReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.time.Duration;
import java.time.LocalDateTime;

@Entity
Expand All @@ -30,9 +29,10 @@ public class CrewReport {
private List<CrewReportKeyword> keywords;

@Builder
public CrewReport(Crew crew, LocalDateTime startedAt) {
public CrewReport(Crew crew, LocalDateTime startedAt, LocalDateTime endAt) {
this.crew = crew;
this.startedAt = startedAt;
this.endAt = endAt;
}

public void updateEndAt(LocalDateTime endAt) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.HttpStatusCode;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestControllerAdvice;
Expand All @@ -26,8 +27,6 @@
@RequiredArgsConstructor
public class ExceptionHandler extends ResponseEntityExceptionHandler {

private final WebhookService webhookService;

@org.springframework.web.bind.annotation.ExceptionHandler
public ResponseEntity<Object> validation(ConstraintViolationException e, WebRequest request) {
return handleExceptionInternal(e, Code.VALIDATION_ERROR, request);
Expand Down Expand Up @@ -66,7 +65,7 @@ private ResponseEntity<Object> handleExceptionInternal(Exception e, Code errorCo

private ResponseEntity<Object> handleExceptionInternal(Exception e, Code errorCode,
HttpHeaders headers, HttpStatus status, WebRequest request) {
webhookService.sendErrorLog(e.getMessage(), e.toString());
WebhookService.sendErrorLog(e.getMessage(), e.toString());
log.error(e.getMessage(), e);

return super.handleExceptionInternal(
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/gsm/blabla/global/response/Code.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public enum Code {
UNSUPPORTED_JWT("AUTH007", HttpStatus.UNAUTHORIZED, "Unsupported jwt format"),
ILLEGAL_JWT("AUTH008", HttpStatus.UNAUTHORIZED, "Illegal jwt format"),
FORBIDDEN("AUTH009", HttpStatus.FORBIDDEN, "Forbidden"),
NO_CREDENTIALS_IN_CONETEXT("AUTH010", HttpStatus.UNAUTHORIZED, "No credentials in Security Context")
NO_CREDENTIALS_IN_CONTEXT("AUTH010", HttpStatus.UNAUTHORIZED, "No credentials in Security Context")
;

private final String code;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/gsm/blabla/global/util/SecurityUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static Long getMemberId() {
final Authentication authentication = SecurityContextHolder.getContext().getAuthentication();

if (authentication == null || authentication.getName() == null || authentication.getName().equals("anonymousUser")) {
throw new GeneralException(Code.NO_CREDENTIALS_IN_CONETEXT, "Security Context에 인증 정보가 없습니다.");
throw new GeneralException(Code.NO_CREDENTIALS_IN_CONTEXT, "Security Context에 인증 정보가 없습니다.");
}

return Long.parseLong(authentication.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
public class WebhookService {

@Value("${discord.webhook.url.dev}")
private String devWebhookUrl;
private static String devWebhookUrl;

@Value("${discord.webhook.url.prod}")
private String prodWebhookUrl;
private static String prodWebhookUrl;

@Value("${spring.profiles.active}")
private String activeProfile;
private static String activeProfile;

public void sendErrorLog(String title, String description) {
public static void sendErrorLog(String title, String description) {
String webhookUrl = "";
if (activeProfile.equals("local")) {
return;
Expand Down
13 changes: 8 additions & 5 deletions src/main/java/com/gsm/blabla/jwt/dto/AppleAccountDto.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
package com.gsm.blabla.jwt.dto;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import lombok.Data;

@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public class AppleAccountDto {

private String iss; // team id
private String exp; // client secret이 만료될 일시
private String iat; // client secret이 생성된 일시
private String sub; // client id
private String at_hash;
private String atHash;
private String email;
private Boolean email_verified;
private Boolean is_private_email;
private String auth_time;
private Boolean nonce_supported;
private Boolean emailVerified;
private Boolean isPrivateEmail;
private String authTime;
private Boolean nonceSupported;
}
5 changes: 5 additions & 0 deletions src/main/java/com/gsm/blabla/jwt/dto/AppleTokenDto.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package com.gsm.blabla.jwt.dto;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import lombok.Data;

@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public class AppleTokenDto {

String accessToken;
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/gsm/blabla/BlablaApplicationTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
@SpringBootTest(properties = "spring.profiles.active=local")
class BlablaApplicationTests {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ void cacelSchedule() {
assertThat(memberScheduleRepository.findByMemberAndSchedule(member1, scheduleRepository.findById(scheduleId)
.orElseThrow(() -> new GeneralException(Code.SCHEDULE_NOT_FOUND, "존재하지 않는 일정입니다."))
).get().getStatus()
).isEqualTo("CANCELED");
).isEqualTo("NOT_JOINED");
}

private ScheduleRequestDto createScheduleRequestDto(String meetingTime) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.web.servlet.MockMvc;

@WebMvcTest(controllers = {
@WebMvcTest(
controllers = {
CrewController.class,
AgoraController.class,
ReportController.class
})
},
properties = "spring.profiles.active=local"
)
public abstract class ControllerTestSupport {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.server.LocalServerPort;

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@SpringBootTest(
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
properties = "spring.profiles.active=local"
)
public abstract class IntegrationTestSupport {

@LocalServerPort
Expand Down Expand Up @@ -154,6 +157,7 @@ protected CrewReport startVoiceRoom(Crew crew, LocalDateTime startedAt) {
CrewReport.builder()
.crew(crew)
.startedAt(startedAt)
.endAt(startedAt.plusMinutes(26).plusSeconds(30))
.build()
);
}
Expand Down Expand Up @@ -182,7 +186,6 @@ protected void createReportAnalysis(CrewReport crewReport, LocalDateTime started
.koreanTime(Duration.ofMinutes(20))
.englishTime(Duration.ofMinutes(6))
.cloudUrl("www.test.com")
.endAt(startedAt.plusMinutes(26).plusSeconds(30))
.build()
);

Expand Down

0 comments on commit 584ac1c

Please sign in to comment.