Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
31d8f9b0aa
|
|||
505b360343
|
|||
51ab19cd8a
|
|||
c8f396a5df
|
|||
4bd6039827
|
|||
80abbda46f
|
|||
a8e85b88d1
|
|||
91baed4fe5
|
|||
2ea261d36a
|
4
.github/workflows/ci-it.yml
vendored
4
.github/workflows/ci-it.yml
vendored
@ -15,10 +15,10 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
jdk: [ 11, 17, 21 ]
|
jdk: [ 11, 17, 21 ]
|
||||||
vault: [ '1.2.0', '1.19.0' ]
|
vault: [ '1.2.0', '1.19.5' ]
|
||||||
include:
|
include:
|
||||||
- jdk: 21
|
- jdk: 21
|
||||||
vault: '1.19.0'
|
vault: '1.19.5'
|
||||||
analysis: true
|
analysis: true
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
|
@ -1,3 +1,12 @@
|
|||||||
|
## 1.5.1 (2025-06-02)
|
||||||
|
|
||||||
|
### Improvements
|
||||||
|
* Use `lookup-self` for token check instead of `lookup` (#98) (#99)
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
* Updated Jackson to 2.19.0 (#97)
|
||||||
|
|
||||||
|
|
||||||
## 1.5.0 (2025-04-13)
|
## 1.5.0 (2025-04-13)
|
||||||
|
|
||||||
### Deprecations
|
### Deprecations
|
||||||
|
@ -28,8 +28,9 @@ Java Vault Connector is a connector library for [Vault](https://www.vaultproject
|
|||||||
* Delete secrets
|
* Delete secrets
|
||||||
* Renew/revoke leases
|
* Renew/revoke leases
|
||||||
* Raw secret content or JSON decoding
|
* Raw secret content or JSON decoding
|
||||||
* SQL secret handling
|
|
||||||
* KV v1 and v2 support
|
* KV v1 and v2 support
|
||||||
|
* Database secret handling
|
||||||
|
* Transit API support
|
||||||
* Connector Factory with builder pattern
|
* Connector Factory with builder pattern
|
||||||
* Tested against Vault 1.2 to 1.19
|
* Tested against Vault 1.2 to 1.19
|
||||||
|
|
||||||
@ -39,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.4.0</version>
|
<version>1.5.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
20
pom.xml
20
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.5.0</version>
|
<version>1.5.1</version>
|
||||||
|
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
@ -33,7 +33,7 @@
|
|||||||
<connection>scm:git:git://github.com/stklcode/jvaultconnector.git</connection>
|
<connection>scm:git:git://github.com/stklcode/jvaultconnector.git</connection>
|
||||||
<developerConnection>scm:git:git@github.com:stklcode/jvaultconnector.git</developerConnection>
|
<developerConnection>scm:git:git@github.com:stklcode/jvaultconnector.git</developerConnection>
|
||||||
<url>https://github.com/stklcode/jvaultconnector</url>
|
<url>https://github.com/stklcode/jvaultconnector</url>
|
||||||
<tag>v1.5.0</tag>
|
<tag>v1.5.1</tag>
|
||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
<issueManagement>
|
<issueManagement>
|
||||||
@ -43,32 +43,32 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.build.outputTimestamp>2025-04-13T09:25:23Z</project.build.outputTimestamp>
|
<project.build.outputTimestamp>2025-06-02T14:59:15Z</project.build.outputTimestamp>
|
||||||
<argLine></argLine>
|
<argLine />
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
<version>2.18.3</version>
|
<version>2.19.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||||
<version>2.18.3</version>
|
<version>2.19.0</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.12.1</version>
|
<version>5.13.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>5.17.0</version>
|
<version>5.18.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -80,7 +80,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.wiremock</groupId>
|
<groupId>org.wiremock</groupId>
|
||||||
<artifactId>wiremock</artifactId>
|
<artifactId>wiremock</artifactId>
|
||||||
<version>3.12.1</version>
|
<version>3.13.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -92,7 +92,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>nl.jqno.equalsverifier</groupId>
|
<groupId>nl.jqno.equalsverifier</groupId>
|
||||||
<artifactId>equalsverifier</artifactId>
|
<artifactId>equalsverifier</artifactId>
|
||||||
<version>3.19.3</version>
|
<version>3.19.4</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -54,6 +54,7 @@ public class HTTPVaultConnector implements VaultConnector {
|
|||||||
private static final String PATH_AUTH = "auth";
|
private static final String PATH_AUTH = "auth";
|
||||||
private static final String PATH_AUTH_TOKEN = PATH_AUTH + "/token";
|
private static final String PATH_AUTH_TOKEN = PATH_AUTH + "/token";
|
||||||
private static final String PATH_LOOKUP = "/lookup";
|
private static final String PATH_LOOKUP = "/lookup";
|
||||||
|
private static final String PATH_LOOKUP_SELF = "/lookup-self";
|
||||||
private static final String PATH_CREATE = "/create";
|
private static final String PATH_CREATE = "/create";
|
||||||
private static final String PATH_ROLES = "/roles";
|
private static final String PATH_ROLES = "/roles";
|
||||||
private static final String PATH_CREATE_ORPHAN = "/create-orphan";
|
private static final String PATH_CREATE_ORPHAN = "/create-orphan";
|
||||||
@ -191,7 +192,7 @@ public class HTTPVaultConnector implements VaultConnector {
|
|||||||
/* set token */
|
/* set token */
|
||||||
this.token = token;
|
this.token = token;
|
||||||
this.tokenTTL = 0;
|
this.tokenTTL = 0;
|
||||||
TokenResponse res = request.post(PATH_AUTH_TOKEN + PATH_LOOKUP, emptyMap(), token, TokenResponse.class);
|
TokenResponse res = request.get(PATH_AUTH_TOKEN + PATH_LOOKUP_SELF, emptyMap(), token, TokenResponse.class);
|
||||||
authorized = true;
|
authorized = true;
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
@ -52,7 +52,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.19.0"; // The vault version this test is supposed to run against.
|
private static String VAULT_VERSION = "1.19.5"; // 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";
|
||||||
|
@ -17,13 +17,13 @@
|
|||||||
package de.stklcode.jvault.connector;
|
package de.stklcode.jvault.connector;
|
||||||
|
|
||||||
import com.github.tomakehurst.wiremock.client.WireMock;
|
import com.github.tomakehurst.wiremock.client.WireMock;
|
||||||
import com.github.tomakehurst.wiremock.junit5.WireMockExtension;
|
import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo;
|
||||||
|
import com.github.tomakehurst.wiremock.junit5.WireMockTest;
|
||||||
import de.stklcode.jvault.connector.exception.ConnectionException;
|
import de.stklcode.jvault.connector.exception.ConnectionException;
|
||||||
import de.stklcode.jvault.connector.exception.InvalidResponseException;
|
import de.stklcode.jvault.connector.exception.InvalidResponseException;
|
||||||
import de.stklcode.jvault.connector.exception.PermissionDeniedException;
|
import de.stklcode.jvault.connector.exception.PermissionDeniedException;
|
||||||
import de.stklcode.jvault.connector.exception.VaultConnectorException;
|
import de.stklcode.jvault.connector.exception.VaultConnectorException;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
|
||||||
import org.junit.jupiter.api.function.Executable;
|
import org.junit.jupiter.api.function.Executable;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -36,9 +36,7 @@ import java.security.cert.CertificateFactory;
|
|||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
|
import static com.github.tomakehurst.wiremock.client.WireMock.*;
|
||||||
import static com.github.tomakehurst.wiremock.client.WireMock.anyUrl;
|
|
||||||
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -48,26 +46,23 @@ import static org.junit.jupiter.api.Assertions.*;
|
|||||||
* @author Stefan Kalscheuer
|
* @author Stefan Kalscheuer
|
||||||
* @since 0.7.0
|
* @since 0.7.0
|
||||||
*/
|
*/
|
||||||
|
@WireMockTest
|
||||||
class HTTPVaultConnectorTest {
|
class HTTPVaultConnectorTest {
|
||||||
@RegisterExtension
|
|
||||||
static WireMockExtension wireMock = WireMockExtension.newInstance()
|
|
||||||
.options(wireMockConfig().dynamicPort())
|
|
||||||
.build();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test exceptions thrown during request.
|
* Test exceptions thrown during request.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
void requestExceptionTest() throws IOException, URISyntaxException {
|
void requestExceptionTest(WireMockRuntimeInfo wireMock) throws IOException, URISyntaxException {
|
||||||
HTTPVaultConnector connector = HTTPVaultConnector.builder(wireMock.url("/")).withTimeout(250).build();
|
HTTPVaultConnector connector = HTTPVaultConnector.builder(wireMock.getHttpBaseUrl()).withTimeout(250).build();
|
||||||
|
|
||||||
// Test invalid response code.
|
// Test invalid response code.
|
||||||
final int responseCode = 400;
|
final int responseCode = 400;
|
||||||
mockHttpResponse(responseCode, "", "application/json");
|
mockHttpResponse(responseCode, "", "application/json");
|
||||||
VaultConnectorException e = assertThrows(
|
VaultConnectorException e = assertThrows(
|
||||||
InvalidResponseException.class,
|
InvalidResponseException.class,
|
||||||
connector::getHealth,
|
connector::getHealth,
|
||||||
"Querying health status succeeded on invalid instance"
|
"Querying health status succeeded on invalid instance"
|
||||||
);
|
);
|
||||||
assertEquals("Invalid response code", e.getMessage(), "Unexpected exception message");
|
assertEquals("Invalid response code", e.getMessage(), "Unexpected exception message");
|
||||||
assertEquals(responseCode, ((InvalidResponseException) e).getStatusCode(), "Unexpected status code in exception");
|
assertEquals(responseCode, ((InvalidResponseException) e).getStatusCode(), "Unexpected status code in exception");
|
||||||
@ -76,9 +71,9 @@ class HTTPVaultConnectorTest {
|
|||||||
// Simulate permission denied response.
|
// Simulate permission denied response.
|
||||||
mockHttpResponse(responseCode, "{\"errors\":[\"permission denied\"]}", "application/json");
|
mockHttpResponse(responseCode, "{\"errors\":[\"permission denied\"]}", "application/json");
|
||||||
assertThrows(
|
assertThrows(
|
||||||
PermissionDeniedException.class,
|
PermissionDeniedException.class,
|
||||||
connector::getHealth,
|
connector::getHealth,
|
||||||
"Querying health status succeeded on invalid instance"
|
"Querying health status succeeded on invalid instance"
|
||||||
);
|
);
|
||||||
|
|
||||||
// Test exception thrown during request.
|
// Test exception thrown during request.
|
||||||
@ -86,22 +81,22 @@ class HTTPVaultConnectorTest {
|
|||||||
connector = HTTPVaultConnector.builder("http://localst:" + s.getLocalPort() + "/").withTimeout(250).build();
|
connector = HTTPVaultConnector.builder("http://localst:" + s.getLocalPort() + "/").withTimeout(250).build();
|
||||||
}
|
}
|
||||||
e = assertThrows(
|
e = assertThrows(
|
||||||
ConnectionException.class,
|
ConnectionException.class,
|
||||||
connector::getHealth,
|
connector::getHealth,
|
||||||
"Querying health status succeeded on invalid instance"
|
"Querying health status succeeded on invalid instance"
|
||||||
);
|
);
|
||||||
assertEquals("Unable to connect to Vault server", e.getMessage(), "Unexpected exception message");
|
assertEquals("Unable to connect to Vault server", e.getMessage(), "Unexpected exception message");
|
||||||
assertInstanceOf(IOException.class, e.getCause(), "Unexpected cause");
|
assertInstanceOf(IOException.class, e.getCause(), "Unexpected cause");
|
||||||
|
|
||||||
// Now simulate a failing request that succeeds on second try.
|
// Now simulate a failing request that succeeds on second try.
|
||||||
connector = HTTPVaultConnector.builder(wireMock.url("/")).withNumberOfRetries(1).withTimeout(250).build();
|
connector = HTTPVaultConnector.builder(wireMock.getHttpBaseUrl()).withNumberOfRetries(1).withTimeout(250).build();
|
||||||
|
|
||||||
wireMock.stubFor(
|
stubFor(
|
||||||
WireMock.any(anyUrl())
|
WireMock.any(anyUrl())
|
||||||
.willReturn(aResponse().withStatus(500))
|
.willReturn(aResponse().withStatus(500))
|
||||||
.willReturn(aResponse().withStatus(500))
|
.willReturn(aResponse().withStatus(500))
|
||||||
.willReturn(aResponse().withStatus(500))
|
.willReturn(aResponse().withStatus(500))
|
||||||
.willReturn(aResponse().withStatus(200).withBody("{}").withHeader("Content-Type", "application/json"))
|
.willReturn(aResponse().withStatus(200).withBody("{}").withHeader("Content-Type", "application/json"))
|
||||||
);
|
);
|
||||||
assertDoesNotThrow(connector::getHealth, "Request failed unexpectedly");
|
assertDoesNotThrow(connector::getHealth, "Request failed unexpectedly");
|
||||||
}
|
}
|
||||||
@ -164,9 +159,9 @@ class HTTPVaultConnectorTest {
|
|||||||
connector = HTTPVaultConnector.builder("http://localst:" + s.getLocalPort()).withTimeout(250).build();
|
connector = HTTPVaultConnector.builder("http://localst:" + s.getLocalPort()).withTimeout(250).build();
|
||||||
}
|
}
|
||||||
ConnectionException e = assertThrows(
|
ConnectionException e = assertThrows(
|
||||||
ConnectionException.class,
|
ConnectionException.class,
|
||||||
connector::sealStatus,
|
connector::sealStatus,
|
||||||
"Querying seal status succeeded on invalid instance"
|
"Querying seal status succeeded on invalid instance"
|
||||||
);
|
);
|
||||||
assertEquals("Unable to connect to Vault server", e.getMessage(), "Unexpected exception message");
|
assertEquals("Unable to connect to Vault server", e.getMessage(), "Unexpected exception message");
|
||||||
}
|
}
|
||||||
@ -182,9 +177,9 @@ class HTTPVaultConnectorTest {
|
|||||||
connector = HTTPVaultConnector.builder("http://localhost:" + s.getLocalPort() + "/").withTimeout(250).build();
|
connector = HTTPVaultConnector.builder("http://localhost:" + s.getLocalPort() + "/").withTimeout(250).build();
|
||||||
}
|
}
|
||||||
ConnectionException e = assertThrows(
|
ConnectionException e = assertThrows(
|
||||||
ConnectionException.class,
|
ConnectionException.class,
|
||||||
connector::getHealth,
|
connector::getHealth,
|
||||||
"Querying health status succeeded on invalid instance"
|
"Querying health status succeeded on invalid instance"
|
||||||
);
|
);
|
||||||
assertEquals("Unable to connect to Vault server", e.getMessage(), "Unexpected exception message");
|
assertEquals("Unable to connect to Vault server", e.getMessage(), "Unexpected exception message");
|
||||||
}
|
}
|
||||||
@ -193,8 +188,8 @@ class HTTPVaultConnectorTest {
|
|||||||
* Test behavior on unparsable responses.
|
* Test behavior on unparsable responses.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
void parseExceptionTest() throws URISyntaxException {
|
void parseExceptionTest(WireMockRuntimeInfo wireMock) throws URISyntaxException {
|
||||||
HTTPVaultConnector connector = HTTPVaultConnector.builder(wireMock.url("/")).withTimeout(250).build();
|
HTTPVaultConnector connector = HTTPVaultConnector.builder(wireMock.getHttpBaseUrl()).withTimeout(250).build();
|
||||||
// Mock authorization.
|
// Mock authorization.
|
||||||
setPrivate(connector, "authorized", true);
|
setPrivate(connector, "authorized", true);
|
||||||
// Mock response.
|
// Mock response.
|
||||||
@ -227,8 +222,8 @@ class HTTPVaultConnectorTest {
|
|||||||
* Test requests that expect an empty response with code 204, but receive a 200 body.
|
* Test requests that expect an empty response with code 204, but receive a 200 body.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
void nonEmpty204ResponseTest() throws URISyntaxException {
|
void nonEmpty204ResponseTest(WireMockRuntimeInfo wireMock) throws URISyntaxException {
|
||||||
HTTPVaultConnector connector = HTTPVaultConnector.builder(wireMock.url("/")).withTimeout(250).build();
|
HTTPVaultConnector connector = HTTPVaultConnector.builder(wireMock.getHttpBaseUrl()).withTimeout(250).build();
|
||||||
// Mock authorization.
|
// Mock authorization.
|
||||||
setPrivate(connector, "authorized", true);
|
setPrivate(connector, "authorized", true);
|
||||||
// Mock response.
|
// Mock response.
|
||||||
@ -236,45 +231,45 @@ class HTTPVaultConnectorTest {
|
|||||||
|
|
||||||
// Now test the methods expecting a 204.
|
// Now test the methods expecting a 204.
|
||||||
assertThrows(
|
assertThrows(
|
||||||
InvalidResponseException.class,
|
InvalidResponseException.class,
|
||||||
() -> connector.createAppRole("appID", Collections.singletonList("policy")),
|
() -> connector.createAppRole("appID", Collections.singletonList("policy")),
|
||||||
"createAppRole() with 200 response succeeded"
|
"createAppRole() with 200 response succeeded"
|
||||||
);
|
);
|
||||||
|
|
||||||
assertThrows(
|
assertThrows(
|
||||||
InvalidResponseException.class,
|
InvalidResponseException.class,
|
||||||
() -> connector.deleteAppRole("roleName"),
|
() -> connector.deleteAppRole("roleName"),
|
||||||
"deleteAppRole() with 200 response succeeded"
|
"deleteAppRole() with 200 response succeeded"
|
||||||
);
|
);
|
||||||
|
|
||||||
assertThrows(
|
assertThrows(
|
||||||
InvalidResponseException.class,
|
InvalidResponseException.class,
|
||||||
() -> connector.setAppRoleID("roleName", "roleID"),
|
() -> connector.setAppRoleID("roleName", "roleID"),
|
||||||
"setAppRoleID() with 200 response succeeded"
|
"setAppRoleID() with 200 response succeeded"
|
||||||
);
|
);
|
||||||
|
|
||||||
assertThrows(
|
assertThrows(
|
||||||
InvalidResponseException.class,
|
InvalidResponseException.class,
|
||||||
() -> connector.destroyAppRoleSecret("roleName", "secretID"),
|
() -> connector.destroyAppRoleSecret("roleName", "secretID"),
|
||||||
"destroyAppRoleSecret() with 200 response succeeded"
|
"destroyAppRoleSecret() with 200 response succeeded"
|
||||||
);
|
);
|
||||||
|
|
||||||
assertThrows(
|
assertThrows(
|
||||||
InvalidResponseException.class,
|
InvalidResponseException.class,
|
||||||
() -> connector.destroyAppRoleSecret("roleName", "secretUD"),
|
() -> connector.destroyAppRoleSecret("roleName", "secretUD"),
|
||||||
"destroyAppRoleSecret() with 200 response succeeded"
|
"destroyAppRoleSecret() with 200 response succeeded"
|
||||||
);
|
);
|
||||||
|
|
||||||
assertThrows(
|
assertThrows(
|
||||||
InvalidResponseException.class,
|
InvalidResponseException.class,
|
||||||
() -> connector.delete("key"),
|
() -> connector.delete("key"),
|
||||||
"delete() with 200 response succeeded"
|
"delete() with 200 response succeeded"
|
||||||
);
|
);
|
||||||
|
|
||||||
assertThrows(
|
assertThrows(
|
||||||
InvalidResponseException.class,
|
InvalidResponseException.class,
|
||||||
() -> connector.revoke("leaseID"),
|
() -> connector.revoke("leaseID"),
|
||||||
"destroyAppRoleSecret() with 200 response succeeded"
|
"destroyAppRoleSecret() with 200 response succeeded"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,10 +305,10 @@ class HTTPVaultConnectorTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void mockHttpResponse(int status, String body, String contentType) {
|
private void mockHttpResponse(int status, String body, String contentType) {
|
||||||
wireMock.stubFor(
|
stubFor(
|
||||||
WireMock.any(anyUrl()).willReturn(
|
WireMock.any(anyUrl()).willReturn(
|
||||||
aResponse().withStatus(status).withBody(body).withHeader("Content-Type", contentType)
|
aResponse().withStatus(status).withBody(body).withHeader("Content-Type", contentType)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user