-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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 #15353 from vsevel/vault_enterprise
Add support for Vault Enterprise Namespace
- Loading branch information
Showing
10 changed files
with
163 additions
and
16 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
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
22 changes: 22 additions & 0 deletions
22
...ns/vault/runtime/src/main/java/io/quarkus/vault/runtime/config/VaultEnterpriseConfig.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 io.quarkus.vault.runtime.config; | ||
|
||
import java.util.Optional; | ||
|
||
import io.quarkus.runtime.annotations.ConfigGroup; | ||
import io.quarkus.runtime.annotations.ConfigItem; | ||
|
||
@ConfigGroup | ||
public class VaultEnterpriseConfig { | ||
|
||
/** | ||
* Vault Enterprise namespace | ||
* <p> | ||
* If set, this will add a `X-Vault-Namespace` header to all requests sent to the Vault server. | ||
* <p> | ||
* See https://www.vaultproject.io/docs/enterprise/namespaces | ||
* | ||
* @asciidoclet | ||
*/ | ||
@ConfigItem | ||
public Optional<String> namespace; | ||
} |
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
33 changes: 33 additions & 0 deletions
33
integration-tests/vault/src/test/java/io/quarkus/vault/VaultEnterpriseITCase.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,33 @@ | ||
package io.quarkus.vault; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import javax.inject.Inject; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.condition.DisabledOnOs; | ||
import org.junit.jupiter.api.condition.OS; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.quarkus.test.common.QuarkusTestResource; | ||
|
||
@DisabledOnOs(OS.WINDOWS) // https://github.com/quarkusio/quarkus/issues/3796 | ||
@QuarkusTestResource(WiremockVault.class) | ||
public class VaultEnterpriseITCase { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addAsResource("application-vault-enterprise.properties", "application.properties")); | ||
|
||
@Inject | ||
VaultKVSecretEngine kvSecretEngine; | ||
|
||
@Test | ||
public void header() { | ||
assertEquals("{hello=world}", kvSecretEngine.readSecret("foo").toString()); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
integration-tests/vault/src/test/java/io/quarkus/vault/WiremockVault.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,43 @@ | ||
package io.quarkus.vault; | ||
|
||
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; | ||
import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; | ||
import static com.github.tomakehurst.wiremock.client.WireMock.get; | ||
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; | ||
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; | ||
|
||
import java.util.Collections; | ||
import java.util.Map; | ||
|
||
import com.github.tomakehurst.wiremock.WireMockServer; | ||
|
||
import io.quarkus.test.common.QuarkusTestResourceLifecycleManager; | ||
|
||
public class WiremockVault implements QuarkusTestResourceLifecycleManager { | ||
|
||
private WireMockServer server; | ||
|
||
@Override | ||
public Map<String, String> start() { | ||
|
||
server = new WireMockServer(wireMockConfig().httpsPort(8201)); | ||
server.start(); | ||
|
||
server.stubFor(get(urlEqualTo("/v1/secret/foo")) | ||
.withHeader("X-Vault-Namespace", equalTo("accounting")) | ||
.willReturn(aResponse() | ||
.withHeader("Content-Type", "application/json") | ||
.withBody( | ||
"{\"request_id\":\"bf5245f4-f194-2b13-80b7-6cad145b8135\",\"lease_id\":\"\",\"renewable\":false,\"lease_duration\":2764800,\"wrap_info\":null,\"warnings\":null,\"auth\":null," | ||
+ "\"data\":{\"hello\":\"world\"}}"))); | ||
|
||
return Collections.emptyMap(); | ||
} | ||
|
||
@Override | ||
public void stop() { | ||
if (server != null) { | ||
server.stop(); | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
integration-tests/vault/src/test/resources/application-vault-enterprise.properties
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,7 @@ | ||
quarkus.vault.url=https://localhost:8201 | ||
quarkus.vault.enterprise.namespace=accounting | ||
quarkus.vault.authentication.client-token=123 | ||
quarkus.vault.kv-secret-engine-version=1 | ||
quarkus.tls.trust-all=true | ||
# CI can sometimes be slow, there is no need to fail a test if Vault doesn't respond in 1 second which is the default | ||
quarkus.vault.read-timeout=5S |
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