Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
11 changed files
with
476 additions
and
1 deletion.
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,71 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
|
||
<parent> | ||
<groupId>org.arquillian.ape</groupId> | ||
<artifactId>arquillian-ape-nosql-parent</artifactId> | ||
<version>2.0.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<properties> | ||
</properties> | ||
|
||
<artifactId>arquillian-ape-nosql-vault-ftest</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<name>Arquillian Ape NoSQL Vault Functional Test</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.lordofthejars</groupId> | ||
<artifactId>nosqlunit-vault</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.bettercloud</groupId> | ||
<artifactId>vault-java-driver</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.arquillian.cube</groupId> | ||
<artifactId>arquillian-cube-docker</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.arquillian.ape</groupId> | ||
<artifactId>arquillian-ape-nosql-vault</artifactId> | ||
<version>${project.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.arquillian.junit</groupId> | ||
<artifactId>arquillian-junit-standalone</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.assertj</groupId> | ||
<artifactId>assertj-core</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<!-- This artifact shouldn't be deployed to maven repository --> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-deploy-plugin</artifactId> | ||
<configuration> | ||
<skip>true</skip> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> | ||
|
22 changes: 22 additions & 0 deletions
22
arquillian-ape-nosql/vault-ftest/src/main/java/org/arquillian/ape/nosql/vault/Secrets.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,22 @@ | ||
package org.arquillian.ape.nosql.vault; | ||
|
||
import com.bettercloud.vault.Vault; | ||
import com.bettercloud.vault.VaultConfig; | ||
import com.bettercloud.vault.VaultException; | ||
import java.util.Map; | ||
|
||
public class Secrets { | ||
|
||
private com.bettercloud.vault.VaultConfig vaultConfig; | ||
private Vault vault; | ||
|
||
public Secrets(String host, int port, String token) throws VaultException { | ||
this.vaultConfig = new VaultConfig(String.format("http://%s:%d", host, port), token); | ||
this.vault = new Vault(this.vaultConfig); | ||
} | ||
|
||
public Map<String, String> getFooSecret() throws VaultException { | ||
return this.vault.logical().read("secret/foo").getData(); | ||
} | ||
|
||
} |
52 changes: 52 additions & 0 deletions
52
arquillian-ape-nosql/vault-ftest/src/test/java/org/arquillian/ape/nosql/vault/VaultTest.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,52 @@ | ||
package org.arquillian.ape.nosql.vault; | ||
|
||
import com.bettercloud.vault.VaultException; | ||
import java.util.Map; | ||
import org.arquillian.ape.nosql.NoSqlPopulator; | ||
import org.arquillian.cube.docker.impl.client.containerobject.dsl.Container; | ||
import org.arquillian.cube.docker.impl.client.containerobject.dsl.DockerContainer; | ||
import org.jboss.arquillian.junit.Arquillian; | ||
import org.jboss.arquillian.test.api.ArquillianResource; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.arquillian.ape.nosql.vault.VaultOptions.options; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@RunWith(Arquillian.class) | ||
public class VaultTest { | ||
|
||
public static final String ROOT_TOKEN = "c56a4180-65aa-42ec-a945-5fd21dec0538"; | ||
@ArquillianResource | ||
@Vault | ||
NoSqlPopulator vaultPopulator; | ||
|
||
@DockerContainer | ||
Container vault = Container.withContainerName("vault") | ||
.fromImage("vault:0.7.0") | ||
.withPortBinding(8200) | ||
.withEnvironment("VAULT_DEV_ROOT_TOKEN_ID", ROOT_TOKEN) | ||
.build(); | ||
|
||
@Test | ||
public void should_read_secrets_from_vault() throws VaultException { | ||
|
||
// given | ||
|
||
vaultPopulator.forServer("http://" + vault.getIpAddress(), vault.getBindPort(8200)) | ||
.usingDataSet("mysecret.yml") | ||
.withOptions(options() | ||
.token(ROOT_TOKEN) | ||
.build()) | ||
.execute(); | ||
|
||
// when | ||
|
||
final Secrets secrets = new Secrets(vault.getIpAddress(), vault.getBindPort(8200), ROOT_TOKEN); | ||
final Map<String, String> data = secrets.getFooSecret(); | ||
|
||
// then | ||
|
||
assertThat(data).containsEntry("zip", "zap").containsEntry("a", "b"); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
arquillian-ape-nosql/vault-ftest/src/test/resources/mysecret.yml
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,3 @@ | ||
- secret/foo: | ||
zip: zap | ||
a: b |
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,40 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
|
||
<parent> | ||
<groupId>org.arquillian.ape</groupId> | ||
<artifactId>arquillian-ape-nosql-parent</artifactId> | ||
<version>2.0.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>arquillian-ape-nosql-vault</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<name>Arquillian Ape NoSQL Vault</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.bettercloud</groupId> | ||
<artifactId>vault-java-driver</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.lordofthejars</groupId> | ||
<artifactId>nosqlunit-vault</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.arquillian.ape</groupId> | ||
<artifactId>arquillian-ape-nosql-core</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
16 changes: 16 additions & 0 deletions
16
arquillian-ape-nosql/vault/src/main/java/org/arquillian/ape/nosql/vault/Vault.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,16 @@ | ||
package org.arquillian.ape.nosql.vault; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
import org.arquillian.ape.api.Populator; | ||
|
||
/** | ||
* Annotation to set Populator of Vault. | ||
*/ | ||
@Populator | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ElementType.FIELD}) | ||
public @interface Vault { | ||
} |
Oops, something went wrong.