Merge branch '2.0.x' into 2.1.x

This commit is contained in:
Spencer Gibb
2019-04-16 14:21:58 -04:00
2 changed files with 170 additions and 14 deletions

View File

@@ -18,16 +18,20 @@ package org.springframework.cloud.config.server.resource;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.test.rule.OutputCapture;
import org.springframework.cloud.config.server.environment.NativeEnvironmentProperties;
import org.springframework.cloud.config.server.environment.NativeEnvironmentRepository;
import org.springframework.cloud.config.server.environment.NativeEnvironmentRepositoryTests;
import org.springframework.context.ConfigurableApplicationContext;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.containsString;
/**
* @author Dave Syer
@@ -35,6 +39,12 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
public class GenericResourceRepositoryTests {
@Rule
public OutputCapture output = new OutputCapture();
@Rule
public ExpectedException exception = ExpectedException.none();
private GenericResourceRepository repository;
private ConfigurableApplicationContext context;
@@ -85,4 +95,12 @@ public class GenericResourceRepositoryTests {
.isNotNull();
}
@Test
public void invalidPath() {
this.exception.expect(NoSuchResourceException.class);
this.nativeRepository.setSearchLocations("file:./src/test/resources/test/{profile}");
this.repository.findOne("blah", "local", "master", "..%2F..%2Fdata-jdbc.sql");
this.output.expect(containsString("Path contains \"../\" after call to StringUtils#cleanPath"));
}
}