Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
61 changes: 44 additions & 17 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,30 +30,37 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<bc-fips.version>2.1.0</bc-fips.version>
<folio-tls-utils.version>4.0.0</folio-tls-utils.version>
<bc-fips.version>2.1.2</bc-fips.version>
<folio-tls-utils.version>4.0.1</folio-tls-utils.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-bom</artifactId>
<version>2.25.1</version>
<version>2.25.4</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-stack-depchain</artifactId>
<version>5.0.3</version>
<version>5.0.10</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>6.0.3</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-bom</artifactId>
<version>1.21.3</version>
<version>2.0.4</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand All @@ -65,18 +72,38 @@
<dependency>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier</artifactId>
<version>3.19.1</version>
<version>4.4.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>5.5.6</version>
<version>5.5.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>vault</artifactId>
<artifactId>testcontainers-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-vault</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -88,7 +115,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.19.0</version>
<version>5.23.0</version>
<scope>test</scope>
</dependency>
<!-- Library provides the basic cryptographic functionality complying with FIPS for testing -->
Expand Down Expand Up @@ -148,7 +175,7 @@
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>ssm</artifactId>
<version>2.32.29</version>
<version>2.42.34</version>
</dependency>
<dependency>
<groupId>org.folio</groupId>
Expand All @@ -174,7 +201,7 @@
<dependency>
<groupId>io.github.jopenlibs</groupId>
<artifactId>vault-java-driver</artifactId>
<version>6.2.0</version>
<version>6.2.1</version>
</dependency>

<!-- we use log4j as our logging implementation -->
Expand All @@ -199,7 +226,7 @@
Java 21 -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.0</version>
<version>3.15.0</version>
<configuration>
<release>21</release>
</configuration>
Expand All @@ -208,7 +235,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>3.1.1</version>
<version>3.3.1</version>
<configuration>
<preparationGoals>clean verify</preparationGoals>
<tagNameFormat>v@{project.version}</tagNameFormat>
Expand All @@ -220,12 +247,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.2</version>
<version>3.5.5</version>
</plugin>

<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.7.1</version>
<version>3.8.0</version>
<executions>
<execution>
<phase>package</phase>
Expand All @@ -250,7 +277,7 @@

<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.1</version>
<version>3.4.0</version>
<executions>
<execution>
<id>attach-sources</id>
Expand All @@ -264,7 +291,7 @@

<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.11.2</version>
<version>3.12.0</version>
<executions>
<execution>
<id>attach-javadocs</id>
Expand Down
1 change: 1 addition & 0 deletions src/assembly/assembly.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<includes>
<include>args4j:args4j</include>
<include>io.vertx:vertx-core</include>
<include>io.vertx:vertx-core-logging</include>
<include>io.netty:netty-buffer</include>
<include>com.fasterxml.jackson.core:jackson-core</include>
<include>com.fasterxml.jackson.core:jackson-databind</include>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,56 @@
import static org.hamcrest.Matchers.is;

import io.vertx.core.Vertx;
import io.vertx.ext.unit.TestContext;
import io.vertx.ext.unit.junit.VertxUnitRunner;
import io.vertx.junit5.VertxExtension;
import io.vertx.junit5.VertxTestContext;
import java.util.Properties;
import org.folio.edge.core.security.SecureStore.NotFoundException;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
import org.testcontainers.vault.VaultContainer;

@RunWith(VertxUnitRunner.class)
public class VaultStoreContainerTest {
@Testcontainers
@ExtendWith(VertxExtension.class)
class VaultStoreContainerTest {

@ClassRule
public static VaultContainer<?> vaultContainer = new VaultContainer<>("vault:1.10.3")
@Container
public static VaultContainer<?> vaultContainer = new VaultContainer<>("hashicorp/vault:1.21")
.withVaultToken("bee")
.withSecretInVault("secret/diku", "diku_admin=password123");
.withInitCommand("kv put secret/diku diku_admin=password123");
private static Properties properties = new Properties();
private static Vertx vertx = Vertx.vertx();

@BeforeClass
public static void beforeClass() {
@BeforeAll
static void beforeClass() {
vaultContainer.followOutput(out -> System.err.println(out.getUtf8String()));
properties.setProperty("token", "bee");
properties.setProperty("address", "http://" + getHostAndPort());
}

private static String getHostAndPort() {
return vaultContainer.getHost() + ":" + vaultContainer.getMappedPort(8200);
properties.setProperty("address", vaultContainer.getHttpHostAddress());
}

@Test
public void get() throws Throwable {
void get() throws Throwable {
assertThat(new VaultStore(properties).get("secret", "diku", "diku_admin"), is("password123"));
}

@Test
public void getSucceededFuture(TestContext context) {
void getSucceededFuture(VertxTestContext vtc) {
new VaultStore(properties).get(vertx, "secret", "diku", "diku_admin")
.onComplete(context.asyncAssertSuccess(value -> assertThat(value, is("password123"))));
.onComplete(vtc.succeeding(value -> {
assertThat(value, is("password123"));
vtc.completeNow();
}));
}

@Test
public void getFailedFuture(TestContext context) {
void getFailedFuture(VertxTestContext vtc) {
new VaultStore(properties).get(vertx, "secret", "diku", "foo")
.onComplete(context.asyncAssertFailure(e -> assertThat(e, is(instanceOf(NotFoundException.class)))));
.onComplete(vtc.failing(e -> {
assertThat(e, is(instanceOf(NotFoundException.class)));
vtc.completeNow();
}));
}

// TODO Add test coverage for SSL/TLS configuration
Expand Down