commit
c86ac9ecaf
|
|
@ -37,6 +37,7 @@ import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
|||
import org.springframework.boot.actuate.endpoint.web.PathMappedEndpoints;
|
||||
import org.springframework.boot.actuate.endpoint.web.WebServerNamespace;
|
||||
import org.springframework.boot.security.reactive.ApplicationContextServerWebExchangeMatcher;
|
||||
import org.springframework.boot.web.context.WebServerApplicationContext;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.core.annotation.MergedAnnotation;
|
||||
import org.springframework.core.annotation.MergedAnnotations;
|
||||
|
|
@ -215,11 +216,15 @@ public final class EndpointRequest {
|
|||
|
||||
protected final boolean hasWebServerNamespace(ApplicationContext applicationContext,
|
||||
WebServerNamespace webServerNamespace) {
|
||||
if (applicationContext.getParent() == null) {
|
||||
return WebServerNamespace.SERVER.equals(webServerNamespace);
|
||||
}
|
||||
String parentContextId = applicationContext.getParent().getId();
|
||||
return applicationContext.getId().equals(parentContextId + ":" + webServerNamespace);
|
||||
return WebServerApplicationContext.hasServerNamespace(applicationContext, webServerNamespace.getValue())
|
||||
|| hasImplicitServerNamespace(applicationContext, webServerNamespace);
|
||||
}
|
||||
|
||||
private boolean hasImplicitServerNamespace(ApplicationContext applicationContext,
|
||||
WebServerNamespace webServerNamespace) {
|
||||
return WebServerNamespace.SERVER.equals(webServerNamespace)
|
||||
&& WebServerApplicationContext.getServerNamespace(applicationContext) == null
|
||||
&& applicationContext.getParent() == null;
|
||||
}
|
||||
|
||||
protected final String toString(List<Object> endpoints, String emptyValue) {
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
|||
import org.springframework.boot.actuate.endpoint.web.PathMappedEndpoint;
|
||||
import org.springframework.boot.actuate.endpoint.web.PathMappedEndpoints;
|
||||
import org.springframework.boot.actuate.endpoint.web.WebServerNamespace;
|
||||
import org.springframework.boot.web.context.WebServerApplicationContext;
|
||||
import org.springframework.boot.web.server.WebServer;
|
||||
import org.springframework.context.support.StaticApplicationContext;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
|
|
@ -39,6 +41,7 @@ import org.springframework.http.server.reactive.ServerHttpResponse;
|
|||
import org.springframework.mock.http.server.reactive.MockServerHttpRequest;
|
||||
import org.springframework.mock.http.server.reactive.MockServerHttpResponse;
|
||||
import org.springframework.security.web.server.util.matcher.ServerWebExchangeMatcher;
|
||||
import org.springframework.web.context.support.StaticWebApplicationContext;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
import org.springframework.web.server.WebHandler;
|
||||
import org.springframework.web.server.adapter.HttpWebHandlerAdapter;
|
||||
|
|
@ -324,10 +327,8 @@ class EndpointRequestTests {
|
|||
PathMappedEndpoints pathMappedEndpoints, WebServerNamespace namespace) {
|
||||
StaticApplicationContext context = new StaticApplicationContext();
|
||||
if (namespace != null && !WebServerNamespace.SERVER.equals(namespace)) {
|
||||
StaticApplicationContext parentContext = new StaticApplicationContext();
|
||||
parentContext.setId("app");
|
||||
NamedStaticWebApplicationContext parentContext = new NamedStaticWebApplicationContext(namespace);
|
||||
context.setParent(parentContext);
|
||||
context.setId(parentContext.getId() + ":" + namespace);
|
||||
}
|
||||
context.registerBean(WebEndpointProperties.class);
|
||||
if (pathMappedEndpoints != null) {
|
||||
|
|
@ -360,6 +361,27 @@ class EndpointRequestTests {
|
|||
return endpoint;
|
||||
}
|
||||
|
||||
static class NamedStaticWebApplicationContext extends StaticWebApplicationContext
|
||||
implements WebServerApplicationContext {
|
||||
|
||||
private final WebServerNamespace webServerNamespace;
|
||||
|
||||
NamedStaticWebApplicationContext(WebServerNamespace webServerNamespace) {
|
||||
this.webServerNamespace = webServerNamespace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebServer getWebServer() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServerNamespace() {
|
||||
return (this.webServerNamespace != null) ? this.webServerNamespace.getValue() : null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static class RequestMatcherAssert implements AssertDelegateTarget {
|
||||
|
||||
private final StaticApplicationContext context;
|
||||
|
|
|
|||
Loading…
Reference in New Issue