This commit is contained in:
Phillip Webb
2017-04-27 12:03:44 -07:00
parent 42e24136ef
commit 45dd9f7144
20 changed files with 75 additions and 71 deletions

View File

@@ -74,39 +74,39 @@ public class AuditEventsMvcEndpointTests {
@Test
public void contentTypeDefaultsToActuatorV2Json() throws Exception {
this.mvc.perform(get("/application/auditevents").param("after", "2016-11-01T10:00:00+0000"))
.andExpect(status().isOk())
this.mvc.perform(get("/application/auditevents").param("after",
"2016-11-01T10:00:00+0000")).andExpect(status().isOk())
.andExpect(header().string("Content-Type",
"application/vnd.spring-boot.actuator.v2+json;charset=UTF-8"));
}
@Test
public void contentTypeCanBeApplicationJson() throws Exception {
this.mvc.perform(get("/application/auditevents").param("after", "2016-11-01T10:00:00+0000")
.header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE))
.andExpect(status().isOk())
.andExpect(header().string("Content-Type",
this.mvc.perform(
get("/application/auditevents").param("after", "2016-11-01T10:00:00+0000")
.header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE))
.andExpect(status().isOk()).andExpect(header().string("Content-Type",
MediaType.APPLICATION_JSON_UTF8_VALUE));
}
@Test
public void invokeWhenDisabledShouldReturnNotFoundStatus() throws Exception {
this.context.getBean(AuditEventsMvcEndpoint.class).setEnabled(false);
this.mvc.perform(get("/application/auditevents").param("after", "2016-11-01T10:00:00+0000"))
.andExpect(status().isNotFound());
this.mvc.perform(get("/application/auditevents").param("after",
"2016-11-01T10:00:00+0000")).andExpect(status().isNotFound());
}
@Test
public void invokeFilterByDateAfter() throws Exception {
this.mvc.perform(get("/application/auditevents").param("after", "2016-11-01T13:00:00+0000"))
.andExpect(status().isOk())
this.mvc.perform(get("/application/auditevents").param("after",
"2016-11-01T13:00:00+0000")).andExpect(status().isOk())
.andExpect(content().string("{\"events\":[]}"));
}
@Test
public void invokeFilterByPrincipalAndDateAfter() throws Exception {
this.mvc.perform(get("/application/auditevents").param("principal", "user").param("after",
"2016-11-01T10:00:00+0000"))
this.mvc.perform(get("/application/auditevents").param("principal", "user")
.param("after", "2016-11-01T10:00:00+0000"))
.andExpect(status().isOk())
.andExpect(content().string(
containsString("\"principal\":\"user\",\"type\":\"login\"")))