Move test security uname/pswd to constants.

parent 61513287
......@@ -22,7 +22,6 @@ import java.util.Map;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
......@@ -47,6 +46,8 @@ import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.springframework.cloud.netflix.test.TestAutoConfiguration.PASSWORD;
import static org.springframework.cloud.netflix.test.TestAutoConfiguration.USER;
/**
* @author Spencer Gibb
......@@ -60,12 +61,6 @@ public class HystrixOnlyTests {
@LocalServerPort
private int port;
//FIXME: 2.0.0
private String username = "user";
//FIXME: 2.0.0
private String password = "password";
@Test
public void testNormalExecution() {
ResponseEntity<String> res = new TestRestTemplate()
......@@ -99,12 +94,10 @@ public class HystrixOnlyTests {
map.containsKey("discovery"));
}
private Map getHealth() {
return new TestRestTemplate().exchange(
"http://localhost:" + this.port + "/admin/health", HttpMethod.GET,
new HttpEntity<Void>(createBasicAuthHeader(username, password)),
new HttpEntity<Void>(createBasicAuthHeader(USER, PASSWORD)),
Map.class).getBody();
}
......
......@@ -38,6 +38,9 @@ import org.springframework.security.provisioning.InMemoryUserDetailsManager;
@AutoConfigureBefore(SecurityAutoConfiguration.class)
public class TestAutoConfiguration {
public static final String USER = "user";
public static final String PASSWORD = "password";
@Configuration
@Order(Ordered.HIGHEST_PRECEDENCE)
protected static class TestSecurityConfiguration extends WebSecurityConfigurerAdapter {
......@@ -50,7 +53,7 @@ public class TestAutoConfiguration {
@Bean
public UserDetailsService userDetailsService() {
InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager();
manager.createUser(User.withUsername("user").password("password").roles("USER").build());
manager.createUser(User.withUsername(USER).password(PASSWORD).roles("USER").build());
return manager;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment