-
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 #9 from mash-up-kr/feature/jasypt
feat: Apply jasypt hoho
- Loading branch information
Showing
7 changed files
with
56 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
jjwtVersion=0.11.5 | ||
mysqlConnectorVersion=8.0.33 | ||
springDocOpenApiVersion=2.0.2 | ||
jasyptVersion=3.0.5 |
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
8 changes: 8 additions & 0 deletions
8
pic-common/src/main/kotlin/com/mashup/pic/config/JasyptConfig.kt
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,8 @@ | ||
package com.mashup.pic.config | ||
|
||
import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties | ||
import org.springframework.context.annotation.Configuration | ||
|
||
@Configuration | ||
@EnableEncryptableProperties | ||
class JasyptConfig |
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,8 @@ | ||
package com.mashup.pic | ||
|
||
import org.springframework.boot.test.context.SpringBootTest | ||
import org.springframework.test.context.TestConstructor | ||
|
||
@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL) | ||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | ||
abstract class SharedContext |
29 changes: 29 additions & 0 deletions
29
pic-common/src/test/kotlin/com/mashup/pic/config/JasyptConfigTest.kt
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,29 @@ | ||
package com.mashup.pic.config | ||
|
||
import com.mashup.pic.SharedContext | ||
import org.hamcrest.Matchers.`is` | ||
import org.hamcrest.MatcherAssert.assertThat | ||
import org.jasypt.encryption.StringEncryptor | ||
import org.junit.jupiter.api.Disabled | ||
import org.junit.jupiter.api.Test | ||
import org.springframework.boot.test.context.SpringBootTest | ||
|
||
/** | ||
* Run > Edit Configurations > Configuration > Environment variables > 'JASYPT_ENCRYPTOR_PASSWORD={암호화키}' 입력 | ||
*/ | ||
@Disabled("암호화, 복호화 결과 확인을 위한 테스트이므로 비활성화") | ||
@SpringBootTest(classes = [JasyptConfig::class]) | ||
class JasyptConfigTest( | ||
private val stringEncryptor: StringEncryptor | ||
) : SharedContext() { | ||
|
||
private val plainText: String = "test" | ||
|
||
@Test | ||
fun execute() { | ||
stringEncryptor.encrypt(plainText).let { encrypted -> | ||
println(encrypted) | ||
assertThat(stringEncryptor.decrypt(encrypted), `is`(plainText)) | ||
} | ||
} | ||
} |