diff --git a/config-client-decrypt/pom.xml b/config-client-decrypt/pom.xml new file mode 100644 index 0000000..cd7e674 --- /dev/null +++ b/config-client-decrypt/pom.xml @@ -0,0 +1,97 @@ + + + 4.0.0 + + org.springframework.cloud + spring-cloud-sample-config-client-decrypt + 1.0.3.BUILD-SNAPSHOT + jar + + spring-cloud-sample-config-client-decrypt + Demo project for Spring Cloud + + + org.springframework.cloud + spring-cloud-starter-parent + 1.0.3.BUILD-SNAPSHOT + + + + + UTF-8 + 1.7 + + + + + + + maven-deploy-plugin + + true + + + + + + + + org.springframework.cloud + spring-cloud-starter-config + + + org.springframework.security + spring-security-rsa + + + org.projectlombok + lombok + true + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + spring-snapshots + Spring Snapshots + https://repo.spring.io/snapshot + + true + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + false + + + + + + spring-snapshots + Spring Snapshots + https://repo.spring.io/snapshot + + true + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + false + + + + + + diff --git a/config-client-decrypt/src/main/java/demo/BootstrapDecryptionClientApplication.java b/config-client-decrypt/src/main/java/demo/BootstrapDecryptionClientApplication.java new file mode 100644 index 0000000..9cf4ada --- /dev/null +++ b/config-client-decrypt/src/main/java/demo/BootstrapDecryptionClientApplication.java @@ -0,0 +1,30 @@ +package demo; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.config.client.ConfigClientProperties; + +/** + * @author Dave Syer + */ +@SpringBootApplication +public class BootstrapDecryptionClientApplication implements CommandLineRunner { + + private static Log logger = LogFactory.getLog(BootstrapDecryptionClientApplication.class); + + @Autowired + private ConfigClientProperties config; + + @Override + public void run(String... args) throws Exception { + logger.info("Config Server URI: " + config.getUri()); + } + + public static void main(String[] args) { + SpringApplication.run(BootstrapDecryptionClientApplication.class, args); + } +} diff --git a/config-client-decrypt/src/main/resources/application.yml b/config-client-decrypt/src/main/resources/application.yml new file mode 100644 index 0000000..ee2a629 --- /dev/null +++ b/config-client-decrypt/src/main/resources/application.yml @@ -0,0 +1,3 @@ +spring: + application: + name: client diff --git a/config-client-decrypt/src/main/resources/bootstrap.yml b/config-client-decrypt/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..9084a0f --- /dev/null +++ b/config-client-decrypt/src/main/resources/bootstrap.yml @@ -0,0 +1,7 @@ +debug: true +encrypt: + key: ${SECRET_KEY:foo} # normally this would be an environment variable +spring: + cloud: + config: + uri: '{cipher}10360db84ecacacf224df3334b02c85b4490b94ee6e6469bf86dd077aa6667f9b84ee3b60343f2c32d61dc14141fe5d0' diff --git a/config-client-decrypt/src/test/java/demo/BootstrapDecryptionClientApplicationTests.java b/config-client-decrypt/src/test/java/demo/BootstrapDecryptionClientApplicationTests.java new file mode 100644 index 0000000..18ac37d --- /dev/null +++ b/config-client-decrypt/src/test/java/demo/BootstrapDecryptionClientApplicationTests.java @@ -0,0 +1,32 @@ +package demo; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.IntegrationTest; +import org.springframework.boot.test.SpringApplicationConfiguration; +import org.springframework.cloud.config.client.ConfigClientProperties; +import org.springframework.cloud.config.client.ConfigServicePropertySourceLocator; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +@RunWith(SpringJUnit4ClassRunner.class) +@SpringApplicationConfiguration(classes = BootstrapDecryptionClientApplication.class) +@IntegrationTest +@DirtiesContext +public class BootstrapDecryptionClientApplicationTests { + + @Autowired + private ConfigClientProperties config; + + @Autowired + private ConfigServicePropertySourceLocator locator; + + @Test + public void contextLoads() throws Exception { + assertEquals("http://localhost:8888", config.getUri()); + } + +} diff --git a/pom.xml b/pom.xml index b991cad..0540998 100644 --- a/pom.xml +++ b/pom.xml @@ -19,6 +19,7 @@ config-client + config-client-decrypt config-retry configserver-eureka eureka-first