-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #164 from BETTER-iTER/feature/163
[FEATURE-163] s3 의존성 변경 및 적용
- Loading branch information
Showing
9 changed files
with
116 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 0 additions & 14 deletions
14
src/main/java/com/example/betteriter/global/config/test/TestSecurityConfig.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/main/java/com/example/betteriter/infra/s3/S3Config.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.example.betteriter.infra.s3; | ||
|
||
import com.amazonaws.auth.AWSCredentials; | ||
import com.amazonaws.auth.AWSStaticCredentialsProvider; | ||
import com.amazonaws.auth.BasicAWSCredentials; | ||
import com.amazonaws.services.s3.AmazonS3; | ||
import com.amazonaws.services.s3.AmazonS3ClientBuilder; | ||
import lombok.Getter; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Getter | ||
@Configuration | ||
public class S3Config { | ||
|
||
@Value("${spring.cloud.aws.credentials.access-key}") | ||
private String accessKey; | ||
|
||
@Value("${spring.cloud.aws.credentials.secret-key}") | ||
private String accessSecret; | ||
|
||
@Value("${spring.cloud.aws.region.static}") | ||
private String region; | ||
|
||
@Bean | ||
public AmazonS3 s3Client() { | ||
AWSCredentials credentials = new BasicAWSCredentials(accessKey, accessSecret); | ||
return AmazonS3ClientBuilder.standard() | ||
.withCredentials(new AWSStaticCredentialsProvider(credentials)) | ||
.withRegion(region).build(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/test/java/com/example/betteriter/global/ConfigTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.example.betteriter.global; | ||
|
||
import com.example.betteriter.infra.s3.S3Config; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Nested; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.TestConfiguration; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; | ||
import org.springframework.test.context.ContextConfiguration; | ||
|
||
@DisplayName("S3Config 설정 클래스는") | ||
@ContextConfiguration(classes = {S3Config.class, ConfigTest.PropertyPlaceholderConfig.class}) | ||
public class ConfigTest { | ||
|
||
@Autowired | ||
private S3Config s3Config; | ||
|
||
@TestConfiguration | ||
static class PropertyPlaceholderConfig { | ||
|
||
@Bean | ||
public static PropertySourcesPlaceholderConfigurer propertiesResolver() { | ||
return new PropertySourcesPlaceholderConfigurer(); | ||
} | ||
} | ||
|
||
@Nested | ||
@DisplayName("각 필드 값을") | ||
class Get_s3_config_values { | ||
|
||
private String accessKey; | ||
private String accessSecret; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
accessKey = s3Config.getAccessKey(); | ||
accessSecret = s3Config.getAccessSecret(); | ||
} | ||
|
||
@Test | ||
@DisplayName("정상적으로 가져온다.") | ||
void With_successful() { | ||
// then | ||
System.out.println("accessKey = " + accessKey); | ||
System.out.println("accessSecret = " + accessSecret); | ||
} | ||
} | ||
} |