Skip to content
Merged
Show file tree
Hide file tree
Changes from 19 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
4 changes: 3 additions & 1 deletion .github/workflows/checkstyle-validation.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
name: 👮Checkstyle validation

on:
push:
branches: [ 1151-feature-42api-모니터링스레드에작업 ]
pull_request:
branches: [ main, dev , recruit-dev]
branches: [ main, dev , recruit-dev ]

jobs:
checkstyle:
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/http-client.env.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dev": {
"name": "value"
}
}
4 changes: 3 additions & 1 deletion .github/workflows/test-code-validation.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
name: 💻 Test code validation

on:
push:
branches: [ 1151-feature-42api-모니터링스레드에작업 ]
pull_request:
branches: [main, dev]
branches: [ main, dev ]

jobs:
test:
Expand Down
51 changes: 1 addition & 50 deletions .github/workflows/test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,9 @@ name: test-deploy

on:
push:
branches: [ dev ]
branches: [ dev, recruit_recruit-dev, 1151-feature-42api-모니터링스레드에작업 ]
workflow_dispatch:

env:
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
IMAGE_NAME: wken5577/test-migrate-server

permissions:
contents: read

Expand All @@ -41,52 +36,8 @@ jobs:
echo "${{ secrets.MIGRATE_APPLICATION_YML }}" | base64 -d > application.yml
shell: bash

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ env.DOCKER_USER }}
password: ${{ env.DOCKER_PASSWORD }}

- name: Test with Gradle
run: ./gradlew clean test

- name: Build with Gradle
run: ./gradlew clean build -x test

- name: build new docker image as latest tag
run: |
docker build -t ${{ env.IMAGE_NAME }}:latest .
docker push ${{ env.IMAGE_NAME }}:latest

- name: Create the configuration file
run: |
cat << EOF > config.json
{
"AutoScalingGroupName": "gg-dev",
"DesiredConfiguration": {
"LaunchTemplate": {
"LaunchTemplateId": "${{ secrets.DEV_LAUNCH_TEMPLATE_ID }}",
"Version": "\$Latest"
}
},
"Preferences": {
"MinHealthyPercentage": 100,
"MaxHealthyPercentage": 110,
"InstanceWarmup": 300,
"ScaleInProtectedInstances": "Ignore",
"StandbyInstances": "Ignore"
}
}
EOF
cat config.json

- name: Configure AWS CLI
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_TEST_MIGRATE_SECURITY_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_TEST_MIGRATE_SECURITY_SECRET_KEY }}
aws-region: ap-northeast-2

- name: Trigger Instance Refresh
run: |
aws autoscaling start-instance-refresh --cli-input-json file://config.json
5 changes: 5 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ plugins {
id 'checkstyle'
}

java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}

editorconfig {
excludes = ['build']
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication(scanBasePackages = {"gg.recruit.api", "gg.utils", "gg.data", "gg.repo",
"gg.admin.repo", "gg.auth", "gg.pingpong.api"})
"gg.admin.repo", "gg.auth", "gg.pingpong.api", "gg.calendar.api"})
public class TestSpringBootApplication {
}
30 changes: 30 additions & 0 deletions gg-auth/src/main/java/gg/auth/FortyTwoAuthUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,21 @@
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;

import gg.auth.config.ScheduleConfig;
import gg.utils.exception.ErrorCode;
import gg.utils.exception.custom.NotExistException;
import gg.utils.exception.user.TokenNotValidException;
import gg.utils.external.ApiUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Component
@RequiredArgsConstructor
public class FortyTwoAuthUtil {
private final ApiUtil apiUtil;
private final OAuth2AuthorizedClientService authorizedClientService;
private final ScheduleConfig scheduleConfig;

public String getAccessToken() {
Authentication authentication = getAuthenticationFromContext();
Expand Down Expand Up @@ -62,6 +66,32 @@
return newClient.getAccessToken().getTokenValue();
}

/* 42event client credential token */
public String getClientCredentialToken() {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);

Check warning on line 72 in gg-auth/src/main/java/gg/auth/FortyTwoAuthUtil.java

View check run for this annotation

Codecov / codecov/patch

gg-auth/src/main/java/gg/auth/FortyTwoAuthUtil.java#L71-L72

Added lines #L71 - L72 were not covered by tests

MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
params.add("grant_type", "client_credentials");
params.add("client_id", scheduleConfig.getClientId());
params.add("client_secret", scheduleConfig.getClientSecret());

Check warning on line 77 in gg-auth/src/main/java/gg/auth/FortyTwoAuthUtil.java

View check run for this annotation

Codecov / codecov/patch

gg-auth/src/main/java/gg/auth/FortyTwoAuthUtil.java#L74-L77

Added lines #L74 - L77 were not covered by tests

try {
Map<String, Object> response = apiUtil.apiCall(
scheduleConfig.getTokenUri(),

Check warning on line 81 in gg-auth/src/main/java/gg/auth/FortyTwoAuthUtil.java

View check run for this annotation

Codecov / codecov/patch

gg-auth/src/main/java/gg/auth/FortyTwoAuthUtil.java#L80-L81

Added lines #L80 - L81 were not covered by tests
Map.class,
headers,
params,
HttpMethod.POST
);
log.info("Raw Api Response : {}", response);

Check warning on line 87 in gg-auth/src/main/java/gg/auth/FortyTwoAuthUtil.java

View check run for this annotation

Codecov / codecov/patch

gg-auth/src/main/java/gg/auth/FortyTwoAuthUtil.java#L87

Added line #L87 was not covered by tests
// System.out.println("Response : " + response);
return (String)response.get("access_token");
} catch (Exception e) {
throw new TokenNotValidException();

Check warning on line 91 in gg-auth/src/main/java/gg/auth/FortyTwoAuthUtil.java

View check run for this annotation

Codecov / codecov/patch

gg-auth/src/main/java/gg/auth/FortyTwoAuthUtil.java#L89-L91

Added lines #L89 - L91 were not covered by tests
}
}

private Authentication getAuthenticationFromContext() {
SecurityContext context = SecurityContextHolder.getContext();
return context.getAuthentication();
Expand Down
17 changes: 17 additions & 0 deletions gg-auth/src/main/java/gg/auth/config/ScheduleConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package gg.auth.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

import lombok.Getter;

@Configuration
@Getter
public class ScheduleConfig {
@Value("${spring.security.oauth2.client.registration.42.client-id}")
private String clientId;
@Value("${spring.security.oauth2.client.registration.42.client-secret}")
private String clientSecret;
@Value("${spring.security.oauth2.client.provider.42.token-uri}")
private String tokenUri;
}
78 changes: 0 additions & 78 deletions gg-calendar-api/src/main/java/gg/api42/ApiClient.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,5 @@ public ResponseEntity<Void> publicScheduleDelete(@PathVariable Long id) {
public ResponseEntity<PublicScheduleAdminResDto> publicScheduleDetail(@PathVariable Long id) {
PublicScheduleAdminResDto publicScheduleAdminResDto = publicScheduleAdminService.detailPublicSchedule(id);
return ResponseEntity.ok(publicScheduleAdminResDto);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public PublicSchedule getPublicScheduleDetailRetrieve(Long scheduleId, Long user
User user = userRepository.getById(userId);
PublicSchedule publicRetrieveSchedule = publicScheduleRepository.findById(scheduleId)
.orElseThrow(() -> new NotExistException(ErrorCode.PUBLIC_SCHEDULE_NOT_FOUND));
checkAuthor(publicRetrieveSchedule.getAuthor(), user);
// checkAuthor(publicRetrieveSchedule.getAuthor(), user);
return publicRetrieveSchedule;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package gg.calendar.api.user.utils.controller.response;

import java.time.LocalDateTime;

import com.fasterxml.jackson.annotation.JsonProperty;

import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class FortyTwoEventResponse {
private Long id;
private String name;
private String description;
private String location;
private String kind;

@JsonProperty("begin_at")
private LocalDateTime beginAt;

@JsonProperty("end_at")
private LocalDateTime endAt;

@JsonProperty("created_at")
private LocalDateTime createdAt;

@JsonProperty("updated_at")
private LocalDateTime updatedAt;

// @JsonProperty("max_people")
// private Integer maxPeople;
//
// @JsonProperty("nbr_subscribers")
// private Integer nbrSubscribers;

// @JsonProperty("campus_ids")
// private List<Integer> campusIds;
//
// @JsonProperty("cursus_ids")
// private List<Integer> cursusIds;

// @JsonProperty("prohibition_of_cancellation")
// private String prohibitionOfCancellation;

// private Waitlist waitlist;
// private List<Themes> themes;

// public static class Themes {
// private Long id;
// private String name;
// @JsonProperty("created_at")
// private LocalDateTime createdAt;
//
// @JsonProperty("updated_at")
// private LocalDateTime updatedAt;
// }
//
// public static class Waitlist {
// private Long id;
// @JsonProperty("created_at")
// private LocalDateTime createdAt;
//
// @JsonProperty("updated_at")
// private LocalDateTime updatedAt;
//
// @JsonProperty("waitlist_id")
// private Long waitlistId;
//
// @JsonProperty("waitlist_type")
// private String waitlistType;
// }

}
Loading
Loading