This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch cyberark-vault-support in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git
commit 52cd73be158bd9471bd32aa5cb11326c812fff0b Author: Andrea Cosentino <[email protected]> AuthorDate: Thu Nov 6 13:43:17 2025 +0100 CAMEL-22664 - Camel-Cyberark-vault Spring Boot: Support Properties function in Spring Boot Signed-off-by: Andrea Cosentino <[email protected]> --- .../SpringBootCyberArkVaultPropertiesParser.java | 106 ++++++++++++++++ .../src/main/resources/META-INF/spring.factories | 19 +++ .../springboot/EarlyResolvedPropertiesTest.java | 119 ++++++++++++++++++ .../src/main/docs/spring-boot.json | 60 +++++++++ .../boot/vault/CyberArkVaultAutoConfiguration.java | 48 +++++++ .../CyberArkVaultConfigurationProperties.java | 140 +++++++++++++++++++++ ...rk.boot.autoconfigure.AutoConfiguration.imports | 1 + .../boot/vault/CyberArkVaultConfigurationTest.java | 52 ++++++++ 8 files changed, 545 insertions(+) diff --git a/components-starter/camel-cyberark-vault-starter/src/main/java/org/apache/camel/component/cyberark/vault/springboot/SpringBootCyberArkVaultPropertiesParser.java b/components-starter/camel-cyberark-vault-starter/src/main/java/org/apache/camel/component/cyberark/vault/springboot/SpringBootCyberArkVaultPropertiesParser.java new file mode 100644 index 00000000000..c6be6f787f4 --- /dev/null +++ b/components-starter/camel-cyberark-vault-starter/src/main/java/org/apache/camel/component/cyberark/vault/springboot/SpringBootCyberArkVaultPropertiesParser.java @@ -0,0 +1,106 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.cyberark.vault.springboot; + +import org.apache.camel.RuntimeCamelException; +import org.apache.camel.component.cyberark.vault.CyberArkVaultPropertiesFunction; +import org.apache.camel.component.cyberark.vault.client.ConjurClient; +import org.apache.camel.component.cyberark.vault.client.ConjurClientFactory; +import org.apache.camel.util.ObjectHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent; +import org.springframework.boot.origin.OriginTrackedValue; +import org.springframework.context.ApplicationListener; +import org.springframework.core.env.ConfigurableEnvironment; +import org.springframework.core.env.MapPropertySource; +import org.springframework.core.env.PropertiesPropertySource; +import org.springframework.core.env.PropertySource; + +import java.util.Properties; + +public class SpringBootCyberArkVaultPropertiesParser implements ApplicationListener<ApplicationEnvironmentPreparedEvent> { + private static final Logger LOG = LoggerFactory.getLogger(SpringBootCyberArkVaultPropertiesParser.class); + + @Override + public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) { + ConjurClient client; + ConfigurableEnvironment environment = event.getEnvironment(); + if (Boolean.parseBoolean(environment.getProperty("camel.component.cyberark-vault.early-resolve-properties"))) { + String url = environment.getProperty("camel.vault.cyberark.url"); + String account = environment.getProperty("camel.vault.cyberark.account"); + String username = environment.getProperty("camel.vault.cyberark.username"); + String password = environment.getProperty("camel.vault.cyberark.password"); + String apiKey = environment.getProperty("camel.vault.cyberark.apiKey"); + String authToken = environment.getProperty("camel.vault.cyberark.authToken"); + + if (ObjectHelper.isNotEmpty(url) && ObjectHelper.isNotEmpty(account)) { + // Create Conjur client based on authentication method + if (ObjectHelper.isNotEmpty(authToken)) { + // Use pre-authenticated token + client = ConjurClientFactory.createWithToken(url, account, authToken); + } else if (ObjectHelper.isNotEmpty(apiKey) && ObjectHelper.isNotEmpty(username)) { + // Use API key authentication + client = ConjurClientFactory.createWithApiKey(url, account, username, apiKey); + } else if (ObjectHelper.isNotEmpty(username) && ObjectHelper.isNotEmpty(password)) { + // Use username/password authentication + client = ConjurClientFactory.createWithCredentials(url, account, username, password); + } else { + throw new RuntimeCamelException( + "Using the CyberArk Conjur Vault Properties Function requires authentication credentials (authToken, apiKey, or username/password)"); + } + } else { + throw new RuntimeCamelException( + "Using the CyberArk Conjur Vault Properties Function requires setting URL and account as application properties or environment variables"); + } + + CyberArkVaultPropertiesFunction cyberArkVaultPropertiesFunction = new CyberArkVaultPropertiesFunction(client); + + final Properties props = new Properties(); + for (PropertySource mutablePropertySources : event.getEnvironment().getPropertySources()) { + if (mutablePropertySources instanceof MapPropertySource mapPropertySource) { + mapPropertySource.getSource().forEach((key, value) -> { + String stringValue = null; + if ((value instanceof OriginTrackedValue originTrackedValue && + originTrackedValue.getValue() instanceof String v)) { + stringValue = v; + } else if (value instanceof String v) { + stringValue = v; + } + + if (stringValue != null && + stringValue.startsWith("{{cyberark:") && + stringValue.endsWith("}}")) { + LOG.debug("decrypting and overriding property {}", key); + try { + String element = cyberArkVaultPropertiesFunction.apply(stringValue + .replace("{{cyberark:", "") + .replace("}}", "")); + props.put(key, element); + } catch (Exception e) { + // Log and do nothing + LOG.debug("failed to parse property {}. This exception is ignored.", key, e); + } + } + }); + } + } + + environment.getPropertySources().addFirst(new PropertiesPropertySource("overridden-camel-cyberark-vault-properties", props)); + } + } +} diff --git a/components-starter/camel-cyberark-vault-starter/src/main/resources/META-INF/spring.factories b/components-starter/camel-cyberark-vault-starter/src/main/resources/META-INF/spring.factories new file mode 100644 index 00000000000..a904bb7cd9d --- /dev/null +++ b/components-starter/camel-cyberark-vault-starter/src/main/resources/META-INF/spring.factories @@ -0,0 +1,19 @@ +## --------------------------------------------------------------------------- +## Licensed to the Apache Software Foundation (ASF) under one or more +## contributor license agreements. See the NOTICE file distributed with +## this work for additional information regarding copyright ownership. +## The ASF licenses this file to You under the Apache License, Version 2.0 +## (the "License"); you may not use this file except in compliance with +## the License. You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## --------------------------------------------------------------------------- + +org.springframework.context.ApplicationListener=\ + org.apache.camel.component.cyberark.vault.springboot.SpringBootCyberArkVaultPropertiesParser diff --git a/components-starter/camel-cyberark-vault-starter/src/test/java/org/apache/camel/component/cyberark/vault/springboot/EarlyResolvedPropertiesTest.java b/components-starter/camel-cyberark-vault-starter/src/test/java/org/apache/camel/component/cyberark/vault/springboot/EarlyResolvedPropertiesTest.java new file mode 100644 index 00000000000..05afecdf83a --- /dev/null +++ b/components-starter/camel-cyberark-vault-starter/src/test/java/org/apache/camel/component/cyberark/vault/springboot/EarlyResolvedPropertiesTest.java @@ -0,0 +1,119 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.cyberark.vault.springboot; + +import org.apache.camel.component.cyberark.vault.client.ConjurClient; +import org.apache.camel.component.cyberark.vault.client.ConjurClientFactory; +import org.apache.camel.spring.boot.CamelAutoConfiguration; +import org.apache.camel.test.spring.junit5.CamelSpringBootTest; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledIfSystemProperties; +import org.junit.jupiter.api.condition.EnabledIfSystemProperty; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.AutoConfigureBefore; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.Configuration; +import org.springframework.test.annotation.DirtiesContext; + +@CamelSpringBootTest +@DirtiesContext +@SpringBootApplication +@SpringBootTest( + classes = { EarlyResolvedPropertiesTest.TestConfiguration.class }, + properties = { + "camel.component.cyberark-vault.early-resolve-properties=true", + "early.resolved.property.simple={{cyberark:test/secret}}" + }) + +// Must be manually tested. Provide your own credentials using system properties: +// -Dcamel.vault.test.cyberark.url, -Dcamel.vault.test.cyberark.account, +// -Dcamel.vault.test.cyberark.username, -Dcamel.vault.test.cyberark.apiKey +@EnabledIfSystemProperties({ + @EnabledIfSystemProperty(named = "camel.vault.test.cyberark.url", matches = ".*", + disabledReason = "CyberArk Conjur URL not provided"), + @EnabledIfSystemProperty(named = "camel.vault.test.cyberark.account", matches = ".*", + disabledReason = "CyberArk Conjur account not provided"), + @EnabledIfSystemProperty(named = "camel.vault.test.cyberark.username", matches = ".*", + disabledReason = "Username not provided"), + @EnabledIfSystemProperty(named = "camel.vault.test.cyberark.apiKey", matches = ".*", + disabledReason = "API key not provided"), +}) +public class EarlyResolvedPropertiesTest { + + @BeforeAll + public static void setup() { + String url = System.getProperty("camel.vault.test.cyberark.url"); + String account = System.getProperty("camel.vault.test.cyberark.account"); + String username = System.getProperty("camel.vault.test.cyberark.username"); + String apiKey = System.getProperty("camel.vault.test.cyberark.apiKey"); + + System.setProperty("camel.vault.cyberark.url", url); + System.setProperty("camel.vault.cyberark.account", account); + System.setProperty("camel.vault.cyberark.username", username); + System.setProperty("camel.vault.cyberark.apiKey", apiKey); + + // Create a test secret in CyberArk Conjur + ConjurClient client = ConjurClientFactory.createWithApiKey(url, account, username, apiKey); + try { + // Note: Creating secrets in Conjur requires proper permissions and policy setup + // This is a placeholder - actual secret creation depends on Conjur policy configuration + // In a real test, you would need to create the secret "test/secret" with value "testValue" + // through Conjur CLI or API with appropriate permissions + } catch (Exception e) { + // Log or handle exception + System.err.println("Warning: Could not create test secret. Ensure 'test/secret' exists in Conjur: " + e.getMessage()); + } finally { + try { + client.close(); + } catch (Exception e) { + // Ignore + } + } + } + + @AfterAll + public static void teardown() { + // Clean up test properties + System.clearProperty("camel.vault.cyberark.url"); + System.clearProperty("camel.vault.cyberark.account"); + System.clearProperty("camel.vault.cyberark.username"); + System.clearProperty("camel.vault.cyberark.apiKey"); + + // Note: CyberArk Conjur secrets cleanup would require proper permissions + // This is typically handled through policy management rather than programmatic deletion + } + + @Value("${early.resolved.property.simple}") + private String earlyResolvedPropertySimple; + + @Test + public void testEarlyResolvedProperties() { + // Verify that the property was resolved from CyberArk Conjur vault + // The actual value depends on what's stored in the 'test/secret' in your Conjur instance + Assertions.assertThat(earlyResolvedPropertySimple).isNotNull(); + Assertions.assertThat(earlyResolvedPropertySimple).isNotEmpty(); + } + + @Configuration + @AutoConfigureBefore(CamelAutoConfiguration.class) + public static class TestConfiguration { + } +} diff --git a/core/camel-spring-boot/src/main/docs/spring-boot.json b/core/camel-spring-boot/src/main/docs/spring-boot.json index 42a117c76eb..909f6df371c 100644 --- a/core/camel-spring-boot/src/main/docs/spring-boot.json +++ b/core/camel-spring-boot/src/main/docs/spring-boot.json @@ -145,6 +145,11 @@ "type": "org.apache.camel.spring.boot.vault.AzureVaultConfigurationProperties", "sourceType": "org.apache.camel.spring.boot.vault.AzureVaultConfigurationProperties" }, + { + "name": "camel.vault.cyberark", + "type": "org.apache.camel.spring.boot.vault.CyberArkVaultConfigurationProperties", + "sourceType": "org.apache.camel.spring.boot.vault.CyberArkVaultConfigurationProperties" + }, { "name": "camel.vault.gcp", "type": "org.apache.camel.spring.boot.vault.GcpVaultConfigurationProperties", @@ -1861,6 +1866,61 @@ "description": "The Vault Name", "sourceType": "org.apache.camel.spring.boot.vault.AzureVaultConfigurationProperties" }, + { + "name": "camel.vault.cyberark.account", + "type": "java.lang.String", + "description": "The CyberArk Conjur account name", + "sourceType": "org.apache.camel.spring.boot.vault.CyberArkVaultConfigurationProperties" + }, + { + "name": "camel.vault.cyberark.api-key", + "type": "java.lang.String", + "description": "The API key for authentication", + "sourceType": "org.apache.camel.spring.boot.vault.CyberArkVaultConfigurationProperties" + }, + { + "name": "camel.vault.cyberark.auth-token", + "type": "java.lang.String", + "description": "Pre-authenticated token to use", + "sourceType": "org.apache.camel.spring.boot.vault.CyberArkVaultConfigurationProperties" + }, + { + "name": "camel.vault.cyberark.certificate-path", + "type": "java.lang.String", + "description": "Path to the SSL certificate for verification", + "sourceType": "org.apache.camel.spring.boot.vault.CyberArkVaultConfigurationProperties" + }, + { + "name": "camel.vault.cyberark.password", + "type": "java.lang.String", + "description": "The password for authentication", + "sourceType": "org.apache.camel.spring.boot.vault.CyberArkVaultConfigurationProperties" + }, + { + "name": "camel.vault.cyberark.secrets", + "type": "java.lang.String", + "description": "Specify the secret names (or pattern) to check for updates. Multiple secrets can be separated by comma.", + "sourceType": "org.apache.camel.spring.boot.vault.CyberArkVaultConfigurationProperties" + }, + { + "name": "camel.vault.cyberark.url", + "type": "java.lang.String", + "description": "The CyberArk Conjur instance URL", + "sourceType": "org.apache.camel.spring.boot.vault.CyberArkVaultConfigurationProperties" + }, + { + "name": "camel.vault.cyberark.username", + "type": "java.lang.String", + "description": "The username for authentication", + "sourceType": "org.apache.camel.spring.boot.vault.CyberArkVaultConfigurationProperties" + }, + { + "name": "camel.vault.cyberark.verify-ssl", + "type": "java.lang.Boolean", + "description": "Whether to verify SSL certificates", + "sourceType": "org.apache.camel.spring.boot.vault.CyberArkVaultConfigurationProperties", + "defaultValue": true + }, { "name": "camel.vault.gcp.project-id", "type": "java.lang.String", diff --git a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/CyberArkVaultAutoConfiguration.java b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/CyberArkVaultAutoConfiguration.java new file mode 100644 index 00000000000..64f693d9f0a --- /dev/null +++ b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/CyberArkVaultAutoConfiguration.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.spring.boot.vault; + +import org.apache.camel.spring.boot.CamelAutoConfiguration; +import org.apache.camel.vault.CyberArkVaultConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration(proxyBeanMethods = false) +@ConditionalOnBean(CamelAutoConfiguration.class) +@EnableConfigurationProperties(CyberArkVaultConfigurationProperties.class) +@AutoConfigureAfter(CamelAutoConfiguration.class) +public class CyberArkVaultAutoConfiguration { + + @Bean + public CyberArkVaultConfiguration cyberarkVaultConfiguration(CyberArkVaultConfigurationProperties config) { + CyberArkVaultConfiguration answer = new CyberArkVaultConfiguration(); + answer.setUrl(config.getUrl()); + answer.setAccount(config.getAccount()); + answer.setUsername(config.getUsername()); + answer.setPassword(config.getPassword()); + answer.setApiKey(config.getApiKey()); + answer.setAuthToken(config.getAuthToken()); + answer.setVerifySsl(config.isVerifySsl()); + answer.setCertificatePath(config.getCertificatePath()); + answer.setSecrets(config.getSecrets()); + return answer; + } + +} diff --git a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/CyberArkVaultConfigurationProperties.java b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/CyberArkVaultConfigurationProperties.java new file mode 100644 index 00000000000..c791f29a59f --- /dev/null +++ b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/CyberArkVaultConfigurationProperties.java @@ -0,0 +1,140 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.spring.boot.vault; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +@ConfigurationProperties(prefix = "camel.vault.cyberark") +public class CyberArkVaultConfigurationProperties { + + /** + * The CyberArk Conjur instance URL + */ + private String url; + + /** + * The CyberArk Conjur account name + */ + private String account; + + /** + * The username for authentication + */ + private String username; + + /** + * The password for authentication + */ + private String password; + + /** + * The API key for authentication + */ + private String apiKey; + + /** + * Pre-authenticated token to use + */ + private String authToken; + + /** + * Whether to verify SSL certificates + */ + private boolean verifySsl = true; + + /** + * Path to the SSL certificate for verification + */ + private String certificatePath; + + /** + * Specify the secret names (or pattern) to check for updates. Multiple secrets can be separated by comma. + */ + private String secrets; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getAccount() { + return account; + } + + public void setAccount(String account) { + this.account = account; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getApiKey() { + return apiKey; + } + + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + } + + public String getAuthToken() { + return authToken; + } + + public void setAuthToken(String authToken) { + this.authToken = authToken; + } + + public boolean isVerifySsl() { + return verifySsl; + } + + public void setVerifySsl(boolean verifySsl) { + this.verifySsl = verifySsl; + } + + public String getCertificatePath() { + return certificatePath; + } + + public void setCertificatePath(String certificatePath) { + this.certificatePath = certificatePath; + } + + public String getSecrets() { + return secrets; + } + + public void setSecrets(String secrets) { + this.secrets = secrets; + } +} diff --git a/core/camel-spring-boot/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/core/camel-spring-boot/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index 251d6b9bcf3..19e4724d726 100644 --- a/core/camel-spring-boot/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/core/camel-spring-boot/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -41,3 +41,4 @@ org.apache.camel.spring.boot.vault.HashicorpVaultAutoConfiguration org.apache.camel.spring.boot.vault.KubernetesVaultAutoConfiguration org.apache.camel.spring.boot.vault.KubernetesConfigMapVaultAutoConfiguration org.apache.camel.spring.boot.vault.IBMVaultAutoConfiguration +org.apache.camel.spring.boot.vault.CyberArkVaultAutoConfiguration diff --git a/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/vault/CyberArkVaultConfigurationTest.java b/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/vault/CyberArkVaultConfigurationTest.java new file mode 100644 index 00000000000..238b0164a1b --- /dev/null +++ b/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/vault/CyberArkVaultConfigurationTest.java @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.spring.boot.vault; + +import org.apache.camel.CamelContext; +import org.apache.camel.test.spring.junit5.CamelSpringBootTest; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.annotation.DirtiesContext; + +@DirtiesContext +@CamelSpringBootTest +@EnableAutoConfiguration +@SpringBootTest(classes = { CyberArkVaultConfigurationTest.class }, properties = { + "camel.vault.cyberark.url=https://conjur.example.com", + "camel.vault.cyberark.account=myAccount", + "camel.vault.cyberark.username=myUsername", + "camel.vault.cyberark.apiKey=myApiKey", + "camel.vault.cyberark.verifySsl=false", + "camel.vault.cyberark.secrets=secret1,secret2" }) +public class CyberArkVaultConfigurationTest { + + @Autowired + private CamelContext camelContext; + + @Test + public void testCyberArkVault() throws Exception { + Assertions.assertEquals("https://conjur.example.com", camelContext.getVaultConfiguration().cyberark().getUrl()); + Assertions.assertEquals("myAccount", camelContext.getVaultConfiguration().cyberark().getAccount()); + Assertions.assertEquals("myUsername", camelContext.getVaultConfiguration().cyberark().getUsername()); + Assertions.assertEquals("myApiKey", camelContext.getVaultConfiguration().cyberark().getApiKey()); + Assertions.assertEquals(false, camelContext.getVaultConfiguration().cyberark().isVerifySsl()); + Assertions.assertEquals("secret1,secret2", camelContext.getVaultConfiguration().cyberark().getSecrets()); + } +}
