Do not require after in audit events endpoint
Closes gh-11605
This commit is contained in:
@@ -25,14 +25,11 @@ include::{snippets}auditevents/filtered/http-response.adoc[]
|
||||
=== Query Parameters
|
||||
|
||||
The endpoint uses query parameters to limit the events that it returns. The following
|
||||
table shows the supported query parameters:
|
||||
table shows the supported query parameters:
|
||||
|
||||
[cols="2,4"]
|
||||
include::{snippets}auditevents/filtered/request-parameters.adoc[]
|
||||
|
||||
The `after` parameter is required. You can also use one or both of the `principal` and
|
||||
`type` parameters to further limit the results.
|
||||
|
||||
|
||||
|
||||
[[audit-events-retrieving-response-structure]]
|
||||
@@ -42,4 +39,4 @@ The response contains details of all of the audit events that matched the query.
|
||||
following table describes the structure of the response:
|
||||
|
||||
[cols="2,1,3"]
|
||||
include::{snippets}auditevents/after/response-fields.adoc[]
|
||||
include::{snippets}auditevents/all/response-fields.adoc[]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,8 +18,6 @@ package org.springframework.boot.actuate.autoconfigure.audit;
|
||||
|
||||
import org.springframework.boot.actuate.audit.AuditEventRepository;
|
||||
import org.springframework.boot.actuate.audit.AuditEventsEndpoint;
|
||||
import org.springframework.boot.actuate.audit.AuditEventsEndpointWebExtension;
|
||||
import org.springframework.boot.actuate.audit.AuditEventsJmxEndpointExtension;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
|
||||
import org.springframework.boot.actuate.logging.LoggersEndpoint;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
@@ -50,22 +48,4 @@ public class AuditEventsEndpointAutoConfiguration {
|
||||
return new AuditEventsEndpoint(auditEventRepository);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@ConditionalOnEnabledEndpoint
|
||||
@ConditionalOnBean(AuditEventsEndpoint.class)
|
||||
public AuditEventsJmxEndpointExtension auditEventsJmxEndpointExtension(
|
||||
AuditEventsEndpoint auditEventsEndpoint) {
|
||||
return new AuditEventsJmxEndpointExtension(auditEventsEndpoint);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@ConditionalOnEnabledEndpoint
|
||||
@ConditionalOnBean(AuditEventsEndpoint.class)
|
||||
public AuditEventsEndpointWebExtension auditEventsWebEndpointExtension(
|
||||
AuditEventsEndpoint auditEventsEndpoint) {
|
||||
return new AuditEventsEndpointWebExtension(auditEventsEndpoint);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,8 +19,6 @@ package org.springframework.boot.actuate.autoconfigure.audit;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.boot.actuate.audit.AuditEventsEndpoint;
|
||||
import org.springframework.boot.actuate.audit.AuditEventsEndpointWebExtension;
|
||||
import org.springframework.boot.actuate.audit.AuditEventsJmxEndpointExtension;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
|
||||
@@ -46,25 +44,11 @@ public class AuditEventsEndpointAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runShouldHaveJmxExtensionBean() {
|
||||
this.contextRunner.run((context) -> assertThat(context)
|
||||
.hasSingleBean(AuditEventsJmxEndpointExtension.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runShouldHaveWebExtensionBean() {
|
||||
this.contextRunner.run((context) -> assertThat(context)
|
||||
.hasSingleBean(AuditEventsEndpointWebExtension.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWhenEnabledPropertyIsFalseShouldNotHaveEndpointOrExtensionBean() {
|
||||
public void runWhenEnabledPropertyIsFalseShouldNotHaveEndpoint() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("management.endpoint.auditevents.enabled:false")
|
||||
.run((context) -> assertThat(context)
|
||||
.doesNotHaveBean(AuditEventsEndpoint.class)
|
||||
.doesNotHaveBean(AuditEventsJmxEndpointExtension.class)
|
||||
.doesNotHaveBean(AuditEventsEndpointWebExtension.class));
|
||||
.doesNotHaveBean(AuditEventsEndpoint.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import org.junit.Test;
|
||||
import org.springframework.boot.actuate.audit.AuditEvent;
|
||||
import org.springframework.boot.actuate.audit.AuditEventRepository;
|
||||
import org.springframework.boot.actuate.audit.AuditEventsEndpoint;
|
||||
import org.springframework.boot.actuate.audit.AuditEventsEndpointWebExtension;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -55,13 +54,13 @@ public class AuditEventsEndpointDocumentationTests
|
||||
private AuditEventRepository repository;
|
||||
|
||||
@Test
|
||||
public void allAuditEventsAfter() throws Exception {
|
||||
public void allAuditEvents() throws Exception {
|
||||
String queryTimestamp = "2017-11-07T09:37Z";
|
||||
given(this.repository.find(any(), any(), any())).willReturn(
|
||||
Arrays.asList(new AuditEvent("alice", "logout", Collections.emptyMap())));
|
||||
this.mockMvc.perform(get("/actuator/auditevents").param("after", queryTimestamp))
|
||||
.andExpect(status().isOk())
|
||||
.andDo(document("auditevents/after", responseFields(
|
||||
.andDo(document("auditevents/all", responseFields(
|
||||
fieldWithPath("events").description("An array of audit events."),
|
||||
fieldWithPath("events.[].timestamp")
|
||||
.description("The timestamp of when the event occurred."),
|
||||
@@ -85,7 +84,7 @@ public class AuditEventsEndpointDocumentationTests
|
||||
requestParameters(
|
||||
parameterWithName("after").description(
|
||||
"Restricts the events to those that occurred "
|
||||
+ "after the given time. Required."),
|
||||
+ "after the given time. Optional."),
|
||||
parameterWithName("principal").description(
|
||||
"Restricts the events to those with the given "
|
||||
+ "principal. Optional."),
|
||||
@@ -104,12 +103,6 @@ public class AuditEventsEndpointDocumentationTests
|
||||
return new AuditEventsEndpoint(repository);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuditEventsEndpointWebExtension adAuditEventsWebEndpointExtension(
|
||||
AuditEventsEndpoint delegate) {
|
||||
return new AuditEventsEndpointWebExtension(delegate);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user