use of org.springframework.cloud.config.environment.Environment in project spring-cloud-config by spring-cloud.
the class JGitEnvironmentRepositoryIntegrationTests method vanilla.
@Test
public void vanilla() throws IOException {
String uri = ConfigServerTestUtils.prepareLocalRepo();
this.context = new SpringApplicationBuilder(TestConfiguration.class).web(WebApplicationType.NONE).properties("spring.cloud.config.server.git.uri:" + uri).run();
EnvironmentRepository repository = this.context.getBean(EnvironmentRepository.class);
repository.findOne("bar", "staging", "master");
Environment environment = repository.findOne("bar", "staging", "master");
assertEquals(2, environment.getPropertySources().size());
assertEquals("bar", environment.getName());
assertArrayEquals(new String[] { "staging" }, environment.getProfiles());
assertEquals("master", environment.getLabel());
}
use of org.springframework.cloud.config.environment.Environment in project spring-cloud-config by spring-cloud.
the class JGitEnvironmentRepositoryTests method basedir.
@Test
public void basedir() {
this.repository.setBasedir(this.basedir);
this.repository.findOne("bar", "staging", "master");
Environment environment = this.repository.findOne("bar", "staging", "master");
assertEquals(2, environment.getPropertySources().size());
assertEquals(this.repository.getUri() + "/bar.properties", environment.getPropertySources().get(0).getName());
assertVersion(environment);
}
use of org.springframework.cloud.config.environment.Environment in project spring-cloud-config by spring-cloud.
the class JGitEnvironmentRepositoryTests method nested.
@Test
public void nested() throws IOException {
String uri = ConfigServerTestUtils.prepareLocalRepo("another-config-repo");
this.repository.setUri(uri);
this.repository.setSearchPaths(new String[] { "sub" });
this.repository.findOne("bar", "staging", "master");
Environment environment = this.repository.findOne("bar", "staging", "master");
assertEquals(2, environment.getPropertySources().size());
assertEquals(this.repository.getUri() + "/sub/application.yml", environment.getPropertySources().get(0).getName());
assertVersion(environment);
}
use of org.springframework.cloud.config.environment.Environment in project spring-cloud-config by spring-cloud.
the class JGitEnvironmentRepositoryTests method nestedPattern.
@Test
public void nestedPattern() throws IOException {
String uri = ConfigServerTestUtils.prepareLocalRepo("another-config-repo");
this.repository.setUri(uri);
this.repository.setSearchPaths(new String[] { "sub*" });
this.repository.findOne("bar", "staging", "master");
Environment environment = this.repository.findOne("bar", "staging", "master");
assertEquals(2, environment.getPropertySources().size());
assertEquals(this.repository.getUri() + "/sub/application.yml", environment.getPropertySources().get(0).getName());
assertVersion(environment);
}
use of org.springframework.cloud.config.environment.Environment in project spring-cloud-config by spring-cloud.
the class CipherEnvironmentEncryptorTests method shouldDecryptEnvironment.
@Test
public void shouldDecryptEnvironment() {
// given
String secret = randomUUID().toString();
// when
Environment environment = new Environment("name", "profile", "label");
environment.add(new PropertySource("a", Collections.<Object, Object>singletonMap(environment.getName(), "{cipher}" + this.textEncryptor.encrypt(secret))));
// then
assertEquals(secret, this.encryptor.decrypt(environment).getPropertySources().get(0).getSource().get(environment.getName()));
}
Aggregations