-
Notifications
You must be signed in to change notification settings - Fork 2
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 #36 from mrFlick72/pipeline_test
Pipeline test
- Loading branch information
Showing
8 changed files
with
149 additions
and
75 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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: template loader | ||
|
||
on: | ||
workflow_dispatch: { } | ||
|
||
jobs: | ||
template-loading: | ||
runs-on: ubuntu-20.04 | ||
|
||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: load templates on s3 | ||
uses: aws-actions/configure-aws-credentials@v1-node16 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ${{ secrets.AWS_REGION }} | ||
- run: | | ||
TEMPLATES=("welcome.html" "mail-verify-challenge.html" "reset-password.html" "successful-mail-verify.html") | ||
for TEMPLATE in ${TEMPLATES[@]} | ||
do | ||
aws s3 cp communication/default/mail/$TEMPLATE s3://${{ secrets.VAUTHENTICATOR_BUCKET }}/mail/templates/$TEMPLATE | ||
done |
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,4 +1,4 @@ | ||
FROM openjdk:17 | ||
FROM amazoncorretto:17.0.4 | ||
|
||
ADD target/vauthenticator.jar /usr/local/vauthenticator/ | ||
|
||
|
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 |
---|---|---|
|
@@ -25,7 +25,7 @@ | |
|
||
<io.mockk.version>1.13.1</io.mockk.version> | ||
<aws.sdk.version>2.17.276</aws.sdk.version> | ||
<greenmail.version>1.6.10</greenmail.version> | ||
<greenmail.version>1.6.11</greenmail.version> | ||
<oauth2-authorization-server.version>0.3.1</oauth2-authorization-server.version> | ||
<wiremock.version>2.27.2</wiremock.version> | ||
</properties> | ||
|
@@ -74,11 +74,6 @@ | |
<version>4.1.1</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.webjars</groupId> | ||
<artifactId>jquery</artifactId> | ||
<version>3.6.1</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.hubspot.jinjava</groupId> | ||
|
@@ -191,13 +186,27 @@ | |
</dependencies> | ||
</dependencyManagement> | ||
|
||
<scm> | ||
<connection>scm:git:${project.scm.url}</connection> | ||
<developerConnection>scm:git:${project.scm.url}</developerConnection> | ||
<url>[email protected]:mrFlick72/vauthenticator.git</url> | ||
<tag>HEAD</tag> | ||
</scm> | ||
|
||
<build> | ||
<finalName>vauthenticator</finalName> | ||
|
||
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory> | ||
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory> | ||
|
||
<plugins> | ||
<plugin> | ||
<artifactId>maven-release-plugin</artifactId> | ||
<configuration> | ||
<scmCommentPrefix>[ci skip]</scmCommentPrefix> | ||
<tagNameFormat>@{project.version}</tagNameFormat> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
|
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
18 changes: 5 additions & 13 deletions
18
src/test/kotlin/it/valeriovaudi/vauthenticator/document/S3DocumentRepositoryTest.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 |
---|---|---|
@@ -1,29 +1,21 @@ | ||
package it.valeriovaudi.vauthenticator.document | ||
|
||
import it.valeriovaudi.vauthenticator.support.DocumentUtils.initDocumentTests | ||
import it.valeriovaudi.vauthenticator.support.DocumentUtils.s3Client | ||
import it.valeriovaudi.vauthenticator.support.TestingFixture.loadFileFor | ||
import org.junit.jupiter.api.Assertions | ||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.Test | ||
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials | ||
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider | ||
import software.amazon.awssdk.regions.Region | ||
import software.amazon.awssdk.services.s3.S3Client.builder | ||
import java.net.URI | ||
|
||
internal class S3DocumentRepositoryTest { | ||
|
||
@Test | ||
internal fun `load document from S3`() { | ||
|
||
val s3Client = builder() | ||
.credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("xxxx", "xxx"))) | ||
.endpointOverride(URI.create("http://localhost:4566")) | ||
.region(Region.US_EAST_1) | ||
.build() | ||
initDocumentTests(s3Client) | ||
|
||
val documentRepository = S3DocumentRepository(s3Client, "bucket") | ||
val document = documentRepository.loadDocument("mail", "templates/welcome.html") | ||
|
||
val expected = loadFileFor("index.html") | ||
Assertions.assertEquals(expected, String(document)) | ||
assertEquals(expected, String(document)) | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
src/test/kotlin/it/valeriovaudi/vauthenticator/support/DocumentUtils.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,45 @@ | ||
package it.valeriovaudi.vauthenticator.support | ||
|
||
import org.springframework.core.io.ClassPathResource | ||
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials | ||
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider | ||
import software.amazon.awssdk.core.sync.RequestBody | ||
import software.amazon.awssdk.regions.Region | ||
import software.amazon.awssdk.services.s3.S3Client | ||
import software.amazon.awssdk.services.s3.model.CreateBucketRequest | ||
import software.amazon.awssdk.services.s3.model.PutObjectRequest | ||
import java.net.URI | ||
|
||
|
||
object DocumentUtils { | ||
private const val documentBucket: String = "bucket" | ||
|
||
val s3Client: S3Client = S3Client.builder() | ||
.credentialsProvider( | ||
StaticCredentialsProvider.create( | ||
AwsBasicCredentials.create("ACCESS_KEY_ID", "SECRET_ACCESS_KEY")) | ||
).region(Region.US_EAST_1) | ||
.endpointOverride(URI.create("http://localhost:4566")) | ||
.build() | ||
|
||
fun initDocumentTests(client: S3Client) { | ||
try { | ||
client.createBucket( | ||
CreateBucketRequest.builder() | ||
.bucket(documentBucket) | ||
.build() | ||
) | ||
}catch (e : Exception){ | ||
|
||
} | ||
|
||
client.putObject( | ||
PutObjectRequest.builder() | ||
.bucket(documentBucket) | ||
.key("mail/templates/welcome.html") | ||
.build(), | ||
RequestBody.fromFile(ClassPathResource("index.html").file) | ||
) | ||
} | ||
|
||
} |