Bael 3329 - Updates to Spring Boot Admin (#7856)

* BAEL-3222 Example Code and update to spring-boot-admin examples

* BAEL-3329 Fix integration tests

* BAEL-3329 Fix integration tests
This commit is contained in:
Amy DeGregorio
2019-09-23 15:41:37 -04:00
committed by maibin
parent 7da66ebd84
commit 933b41c8b5
7 changed files with 52 additions and 39 deletions

View File

@@ -15,7 +15,7 @@ import static org.junit.Assert.assertEquals;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.httpBasic;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.springframework.security.test.web.servlet.response.SecurityMockMvcResultMatchers.unauthenticated;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = RANDOM_PORT)
@@ -36,20 +36,20 @@ public class SpringBootAdminClientApplicationIntegrationTest {
@Test
public void whenEnvironmentAvailable_ThenAdminServerPropertiesExist() {
assertEquals(environment.getProperty("spring.boot.admin.url"), "http://localhost:8080");
assertEquals(environment.getProperty("spring.boot.admin.username"), "admin");
assertEquals(environment.getProperty("spring.boot.admin.password"), "admin");
assertEquals(environment.getProperty("spring.boot.admin.client.url"), "http://localhost:8080");
assertEquals(environment.getProperty("spring.boot.admin.client.username"), "admin");
assertEquals(environment.getProperty("spring.boot.admin.client.password"), "admin");
}
@Test
public void whenHttpBasicAttempted_ThenSuccess() throws Exception {
mockMvc.perform(get("/env").with(httpBasic("client", "client")));
mockMvc.perform(get("/actuator/env").with(httpBasic("client", "client")));
}
@Test
public void whenInvalidHttpBasicAttempted_ThenUnauthorized() throws Exception {
mockMvc
.perform(get("/env").with(httpBasic("client", "invalid")))
.andExpect(status().isUnauthorized());
.perform(get("/actuator/env").with(httpBasic("client", "invalid")))
.andExpect(unauthenticated());
}
}