Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
2412a291f6
|
|||
b5ed7704e3
|
|||
a1626aa1c7
|
|||
3fb8454711
|
|||
ecf18881b9
|
|||
69287f7196
|
|||
4b1b4399e1
|
31
.drone.yml
31
.drone.yml
@ -3,7 +3,7 @@ name: default
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: compile
|
- name: compile
|
||||||
image: maven:3-jdk-11
|
image: maven:3-openjdk-17
|
||||||
commands:
|
commands:
|
||||||
- mvn -B clean compile
|
- mvn -B clean compile
|
||||||
when:
|
when:
|
||||||
@ -14,7 +14,7 @@ steps:
|
|||||||
- fix/*
|
- fix/*
|
||||||
- release/*
|
- release/*
|
||||||
- name: unit-tests
|
- name: unit-tests
|
||||||
image: maven:3-jdk-11
|
image: maven:3-openjdk-17
|
||||||
commands:
|
commands:
|
||||||
- mvn -B test
|
- mvn -B test
|
||||||
when:
|
when:
|
||||||
@ -22,16 +22,27 @@ steps:
|
|||||||
- develop
|
- develop
|
||||||
- feature/*
|
- feature/*
|
||||||
- fix/*
|
- fix/*
|
||||||
- name: unit-integration-tests
|
- name: setup-vault
|
||||||
image: maven:3-jdk-11
|
image: alpine:latest
|
||||||
environment:
|
environment:
|
||||||
VAULT_VERSION: 1.10.1
|
VAULT_VERSION: 1.11.2
|
||||||
commands:
|
commands:
|
||||||
- curl -s -o vault_1.10.1_linux_amd64.zip https://releases.hashicorp.com/vault/1.10.1/vault_1.10.1_linux_amd64.zip
|
- wget -q -O vault_$${VAULT_VERSION}_linux_amd64.zip https://releases.hashicorp.com/vault/$${VAULT_VERSION}/vault_$${VAULT_VERSION}_linux_amd64.zip
|
||||||
- curl -s https://releases.hashicorp.com/vault/1.10.1/vault_1.10.1_SHA256SUMS | grep linux_amd64 | sha256sum -c
|
- wget -q -O - https://releases.hashicorp.com/vault/$${VAULT_VERSION}/vault_$${VAULT_VERSION}_SHA256SUMS | grep linux_amd64 | sha256sum -c
|
||||||
- unzip vault_1.10.1_linux_amd64.zip
|
- unzip vault_$${VAULT_VERSION}_linux_amd64.zip
|
||||||
- rm vault_1.10.1_linux_amd64.zip
|
- rm vault_$${VAULT_VERSION}_linux_amd64.zip
|
||||||
- mv vault /bin/
|
- mkdir -p .bin
|
||||||
|
- mv vault .bin/
|
||||||
|
when:
|
||||||
|
branch:
|
||||||
|
- main
|
||||||
|
- release/*
|
||||||
|
- name: unit-integration-tests
|
||||||
|
image: maven:3-openjdk-17
|
||||||
|
environment:
|
||||||
|
VAULT_VERSION: 1.11.2
|
||||||
|
commands:
|
||||||
|
- export PATH=.bin:$${PATH}
|
||||||
- mvn -B -P integration-test verify
|
- mvn -B -P integration-test verify
|
||||||
when:
|
when:
|
||||||
branch:
|
branch:
|
||||||
|
12
.github/workflows/ci.yml
vendored
12
.github/workflows/ci.yml
vendored
@ -5,19 +5,19 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
jdk: [ 11, 17 ]
|
jdk: [ 11, 17, 18 ]
|
||||||
vault: [ '1.10.1' ]
|
vault: [ '1.11.2' ]
|
||||||
include:
|
include:
|
||||||
- jdk: 11
|
- jdk: 17
|
||||||
vault: '1.10.1'
|
vault: '1.11.2'
|
||||||
analysis: true
|
analysis: true
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Set up Java
|
- name: Set up Java
|
||||||
uses: actions/setup-java@v2
|
uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
java-version: ${{ matrix.jdk }}
|
java-version: ${{ matrix.jdk }}
|
||||||
distribution: 'temurin'
|
distribution: 'temurin'
|
||||||
|
10
CHANGELOG.md
10
CHANGELOG.md
@ -1,3 +1,13 @@
|
|||||||
|
## 1.1.1 (2022-08-29)
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
* Updated Jackson to 2.13.3
|
||||||
|
|
||||||
|
### Test
|
||||||
|
* Tested against Vault 1.11.2
|
||||||
|
* Tested with Java 18
|
||||||
|
|
||||||
|
|
||||||
## 1.1.0 (2022-04-24)
|
## 1.1.0 (2022-04-24)
|
||||||
|
|
||||||
### Fix
|
### Fix
|
||||||
|
@ -32,7 +32,7 @@ Java Vault Connector is a connector library for [Vault](https://www.vaultproject
|
|||||||
* SQL secret handling
|
* SQL secret handling
|
||||||
* KV v1 and v2 support
|
* KV v1 and v2 support
|
||||||
* Connector Factory with builder pattern
|
* Connector Factory with builder pattern
|
||||||
* Tested against Vault 1.10.1
|
* Tested against Vault 1.11.2
|
||||||
|
|
||||||
|
|
||||||
## Maven Artifact
|
## Maven Artifact
|
||||||
@ -40,7 +40,7 @@ Java Vault Connector is a connector library for [Vault](https://www.vaultproject
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>de.stklcode.jvault</groupId>
|
<groupId>de.stklcode.jvault</groupId>
|
||||||
<artifactId>jvault-connector</artifactId>
|
<artifactId>jvault-connector</artifactId>
|
||||||
<version>1.1.0</version>
|
<version>1.1.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
28
pom.xml
28
pom.xml
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<groupId>de.stklcode.jvault</groupId>
|
<groupId>de.stklcode.jvault</groupId>
|
||||||
<artifactId>jvault-connector</artifactId>
|
<artifactId>jvault-connector</artifactId>
|
||||||
<version>1.1.0</version>
|
<version>1.1.1</version>
|
||||||
|
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
@ -67,7 +67,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-resources-plugin</artifactId>
|
<artifactId>maven-resources-plugin</artifactId>
|
||||||
<version>3.2.0</version>
|
<version>3.3.0</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
@ -84,12 +84,12 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-install-plugin</artifactId>
|
<artifactId>maven-install-plugin</artifactId>
|
||||||
<version>2.5.2</version>
|
<version>3.0.1</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-deploy-plugin</artifactId>
|
<artifactId>maven-deploy-plugin</artifactId>
|
||||||
<version>2.8.2</version>
|
<version>3.0.0</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
@ -116,19 +116,19 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
<version>2.13.2.2</version>
|
<version>2.13.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.junit.jupiter</groupId>
|
<groupId>org.junit.jupiter</groupId>
|
||||||
<artifactId>junit-jupiter</artifactId>
|
<artifactId>junit-jupiter</artifactId>
|
||||||
<version>5.8.2</version>
|
<version>5.9.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mockito</groupId>
|
<groupId>org.mockito</groupId>
|
||||||
<artifactId>mockito-core</artifactId>
|
<artifactId>mockito-core</artifactId>
|
||||||
<version>4.5.1</version>
|
<version>4.7.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -140,7 +140,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.tomakehurst</groupId>
|
<groupId>com.github.tomakehurst</groupId>
|
||||||
<artifactId>wiremock-jre8</artifactId>
|
<artifactId>wiremock-jre8</artifactId>
|
||||||
<version>2.33.1</version>
|
<version>2.33.2</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -152,7 +152,13 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>nl.jqno.equalsverifier</groupId>
|
<groupId>nl.jqno.equalsverifier</groupId>
|
||||||
<artifactId>equalsverifier</artifactId>
|
<artifactId>equalsverifier</artifactId>
|
||||||
<version>3.10</version>
|
<version>3.10.1</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.awaitility</groupId>
|
||||||
|
<artifactId>awaitility</artifactId>
|
||||||
|
<version>4.2.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
@ -203,7 +209,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
<version>3.4.0</version>
|
<version>3.4.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>11</source>
|
<source>11</source>
|
||||||
</configuration>
|
</configuration>
|
||||||
@ -300,7 +306,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.owasp</groupId>
|
<groupId>org.owasp</groupId>
|
||||||
<artifactId>dependency-check-maven</artifactId>
|
<artifactId>dependency-check-maven</artifactId>
|
||||||
<version>7.1.0</version>
|
<version>7.1.2</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
|
@ -37,6 +37,7 @@ import java.util.regex.Pattern;
|
|||||||
|
|
||||||
import static java.util.Collections.singletonMap;
|
import static java.util.Collections.singletonMap;
|
||||||
import static org.apache.commons.io.FileUtils.copyDirectory;
|
import static org.apache.commons.io.FileUtils.copyDirectory;
|
||||||
|
import static org.awaitility.Awaitility.await;
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
import static org.junit.jupiter.api.Assumptions.assumeFalse;
|
import static org.junit.jupiter.api.Assumptions.assumeFalse;
|
||||||
import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
||||||
@ -49,7 +50,7 @@ import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
|||||||
* @since 0.1
|
* @since 0.1
|
||||||
*/
|
*/
|
||||||
class HTTPVaultConnectorIT {
|
class HTTPVaultConnectorIT {
|
||||||
private static String VAULT_VERSION = "1.10.1"; // The vault version this test is supposed to run against.
|
private static String VAULT_VERSION = "1.11.2"; // The vault version this test is supposed to run against.
|
||||||
private static final String KEY1 = "E38bkCm0VhUvpdCKGQpcohhD9XmcHJ/2hreOSY019Lho";
|
private static final String KEY1 = "E38bkCm0VhUvpdCKGQpcohhD9XmcHJ/2hreOSY019Lho";
|
||||||
private static final String KEY2 = "O5OHwDleY3IiPdgw61cgHlhsrEm6tVJkrxhF6QAnILd1";
|
private static final String KEY2 = "O5OHwDleY3IiPdgw61cgHlhsrEm6tVJkrxhF6QAnILd1";
|
||||||
private static final String KEY3 = "mw7Bm3nbt/UWa/juDjjL2EPQ04kiJ0saC5JEXwJvXYsB";
|
private static final String KEY3 = "mw7Bm3nbt/UWa/juDjjL2EPQ04kiJ0saC5JEXwJvXYsB";
|
||||||
@ -80,11 +81,6 @@ class HTTPVaultConnectorIT {
|
|||||||
|
|
||||||
// Initialize Vault.
|
// Initialize Vault.
|
||||||
VaultConfiguration config = initializeVault(tempDir, isTls);
|
VaultConfiguration config = initializeVault(tempDir, isTls);
|
||||||
try {
|
|
||||||
TimeUnit.SECONDS.sleep(1);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize connector.
|
// Initialize connector.
|
||||||
HTTPVaultConnectorBuilder builder = HTTPVaultConnector.builder()
|
HTTPVaultConnectorBuilder builder = HTTPVaultConnector.builder()
|
||||||
@ -908,7 +904,8 @@ class HTTPVaultConnectorIT {
|
|||||||
assertFalse(res.getAuth().isOrphan(), "Root token should not be orphan");
|
assertFalse(res.getAuth().isOrphan(), "Root token should not be orphan");
|
||||||
|
|
||||||
// Starting with Vault 1.0 a warning "custom ID uses weaker SHA1.." is given.
|
// Starting with Vault 1.0 a warning "custom ID uses weaker SHA1.." is given.
|
||||||
assertEquals(1, res.getWarnings().size(), "Token creation did not return expected warning");
|
// Starting with Vault 1.11 a second warning "Endpoint ignored unrecognized parameters" is given.
|
||||||
|
assertFalse(res.getWarnings().isEmpty(), "Token creation did not return expected warning");
|
||||||
|
|
||||||
// Create token with attributes.
|
// Create token with attributes.
|
||||||
Token token2 = Token.builder()
|
Token token2 = Token.builder()
|
||||||
@ -1221,30 +1218,37 @@ class HTTPVaultConnectorIT {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write configuration file.
|
// Write configuration file.
|
||||||
BufferedWriter bw = null;
|
File configFile = new File(dir, "vault.conf");
|
||||||
File configFile;
|
try (BufferedWriter bw = new BufferedWriter(new FileWriter(configFile))) {
|
||||||
try {
|
|
||||||
configFile = new File(dir, "vault.conf");
|
|
||||||
bw = new BufferedWriter(new FileWriter(configFile));
|
|
||||||
bw.write(config.toString());
|
bw.write(config.toString());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new IllegalStateException("Unable to generate config file", e);
|
throw new IllegalStateException("Unable to generate config file", e);
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if (bw != null)
|
|
||||||
bw.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start vault process.
|
// Start vault process.
|
||||||
try {
|
try {
|
||||||
vaultProcess = Runtime.getRuntime().exec("vault server -config " + configFile.toString());
|
vaultProcess = Runtime.getRuntime().exec("vault server -config " + configFile);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new IllegalStateException("Unable to start vault. Make sure vault binary is in your executable path", e);
|
throw new IllegalStateException("Unable to start vault. Make sure vault binary is in your executable path", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await().atMost(5, TimeUnit.SECONDS).until(() -> {
|
||||||
|
try (InputStream stdout = vaultProcess.getInputStream();
|
||||||
|
InputStreamReader reader = new InputStreamReader(stdout);
|
||||||
|
BufferedReader br = new BufferedReader(reader)) {
|
||||||
|
String line = br.readLine();
|
||||||
|
while (line != null) {
|
||||||
|
if (line.contains("Vault server started")) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
line = br.readLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1269,28 +1273,14 @@ class HTTPVaultConnectorIT {
|
|||||||
* @return port number
|
* @return port number
|
||||||
*/
|
*/
|
||||||
private static Integer getFreePort() {
|
private static Integer getFreePort() {
|
||||||
ServerSocket socket = null;
|
try (ServerSocket socket = new ServerSocket(0)) {
|
||||||
try {
|
|
||||||
socket = new ServerSocket(0);
|
|
||||||
socket.setReuseAddress(true);
|
socket.setReuseAddress(true);
|
||||||
int port = socket.getLocalPort();
|
|
||||||
try {
|
return socket.getLocalPort();
|
||||||
socket.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
// Ignore IOException on close()
|
|
||||||
}
|
|
||||||
return port;
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
|
||||||
if (socket != null) {
|
|
||||||
try {
|
|
||||||
socket.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new IllegalStateException("Unable to find a free TCP port");
|
throw new IllegalStateException("Unable to find a free TCP port");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user