You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2022/06/09 09:56:49 UTC
[camel] 04/04: CAMEL-17689 - Create a Camel Hashicorp Vault Component - Read Secret operation
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 5ed03d60b88d0e7d60966eebfa78f573b80515c1
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Jun 9 10:52:32 2022 +0200
CAMEL-17689 - Create a Camel Hashicorp Vault Component - Read Secret operation
---
.../operations/HashicorpProducerReadSecretIT.java | 66 ++++++++++++++++++++++
1 file changed, 66 insertions(+)
diff --git a/components/camel-hashicorp-vault/src/test/java/org/apache/camel/component/hashicorp/vault/integration/operations/HashicorpProducerReadSecretIT.java b/components/camel-hashicorp-vault/src/test/java/org/apache/camel/component/hashicorp/vault/integration/operations/HashicorpProducerReadSecretIT.java
new file mode 100644
index 00000000000..045092a9070
--- /dev/null
+++ b/components/camel-hashicorp-vault/src/test/java/org/apache/camel/component/hashicorp/vault/integration/operations/HashicorpProducerReadSecretIT.java
@@ -0,0 +1,66 @@
+package org.apache.camel.component.hashicorp.vault.integration.operations;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.hashicorp.vault.HashicorpVaultConstants;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+@Disabled("Disabled until we'll have a Camel-Hashicorp-vault test-infra module")
+public class HashicorpProducerReadSecretIT extends CamelTestSupport {
+
+ @EndpointInject("mock:result")
+ private MockEndpoint mock;
+
+ @Test
+ public void createSecretTest() throws InterruptedException {
+
+ mock.expectedMessageCount(1);
+ Exchange exchange = template.request("direct:readSecret", new Processor() {
+ @Override
+ public void process(Exchange exchange) {
+ exchange.getMessage().setHeader(HashicorpVaultConstants.SECRET_PATH, "myapp");
+ }
+ });
+
+ assertMockEndpointsSatisfied();
+ Exchange ret = mock.getExchanges().get(0);
+ assertNotNull(ret);
+ assertEquals(((Map)ret.getMessage().getBody(Map.class).get("data")).get("id"), "12");
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("direct:readSecret")
+ .to("hashicorp-vault://secret?operation=getSecret&token=RAW(token)&host=localhost&scheme=http")
+ .to("mock:result");
+ }
+ };
+ }
+
+ class Secrets {
+
+ String username;
+ String password;
+
+ public String getUsername() {
+ return username;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+ }
+}