Closed dasd412 closed 2 years ago
when CI / CD, we MUST NOT push these properties into GitHub Repository because this is our secret!
So, we use .gitignore
and make direcory for these secret properties in our AWS servers.
But dillema arises when CI. GitHub actions cannot find these properties!! And we must not push into git repo!!
My solution is "make mock properties. and include them in test properties."
For example, I made application-email-mock.properties
like below.
spring.mail.host=smtp.test.com
spring.mail.port=1111
spring.mail.username=mock@test.com
spring.mail.password=ThisISmock
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.ssl.enable=true
spring.mail.properties.mail.smtp.trust=smtp.test.com
when testing, application usually dosen't use these attributes. So, just write any string.
Then we should include properties in properties for only test.
# inject mockito properties
spring.profiles.include=database-mock,oauth-mock,email-mock
NOTE
I wrote @TestPropertySource(locations = "classpath:application-test.properties")
annotation in test classes.
GitHub Actions log below describes error about external properties. In other words, This error means that spring can't find that properties.
When we code and test in local environment, we don't need to care about this kind of issues.
Why? That's because we locate secret properties ( example : email.properties, database.properties ... etc) on directory
classpath:/src/resources/
!