Search in sources :

Example 1 with ExposableEndpoint

use of org.springframework.boot.actuate.endpoint.ExposableEndpoint in project spring-boot by spring-projects.

the class EndpointRequestTests method excludeByClassShouldNotMatchExcluded.

@Test
void excludeByClassShouldNotMatchExcluded() {
    RequestMatcher matcher = EndpointRequest.toAnyEndpoint().excluding(FooEndpoint.class, BazServletEndpoint.class);
    List<ExposableEndpoint<?>> endpoints = new ArrayList<>();
    endpoints.add(mockEndpoint(EndpointId.of("foo"), "foo"));
    endpoints.add(mockEndpoint(EndpointId.of("bar"), "bar"));
    endpoints.add(mockEndpoint(EndpointId.of("baz"), "baz"));
    PathMappedEndpoints pathMappedEndpoints = new PathMappedEndpoints("/actuator", () -> endpoints);
    assertMatcher(matcher, pathMappedEndpoints).doesNotMatch("/actuator/foo");
    assertMatcher(matcher, pathMappedEndpoints).doesNotMatch("/actuator/baz");
    assertMatcher(matcher).matches("/actuator/bar");
    assertMatcher(matcher).matches("/actuator");
}
Also used : RequestMatcher(org.springframework.security.web.util.matcher.RequestMatcher) ExposableEndpoint(org.springframework.boot.actuate.endpoint.ExposableEndpoint) ArrayList(java.util.ArrayList) PathMappedEndpoints(org.springframework.boot.actuate.endpoint.web.PathMappedEndpoints) Test(org.junit.jupiter.api.Test)

Example 2 with ExposableEndpoint

use of org.springframework.boot.actuate.endpoint.ExposableEndpoint in project spring-boot by spring-projects.

the class WebFluxEndpointManagementContextConfiguration method webEndpointReactiveHandlerMapping.

@Bean
@ConditionalOnMissingBean
public WebFluxEndpointHandlerMapping webEndpointReactiveHandlerMapping(WebEndpointsSupplier webEndpointsSupplier, ControllerEndpointsSupplier controllerEndpointsSupplier, EndpointMediaTypes endpointMediaTypes, CorsEndpointProperties corsProperties, WebEndpointProperties webEndpointProperties, Environment environment) {
    String basePath = webEndpointProperties.getBasePath();
    EndpointMapping endpointMapping = new EndpointMapping(basePath);
    Collection<ExposableWebEndpoint> endpoints = webEndpointsSupplier.getEndpoints();
    List<ExposableEndpoint<?>> allEndpoints = new ArrayList<>();
    allEndpoints.addAll(endpoints);
    allEndpoints.addAll(controllerEndpointsSupplier.getEndpoints());
    return new WebFluxEndpointHandlerMapping(endpointMapping, endpoints, endpointMediaTypes, corsProperties.toCorsConfiguration(), new EndpointLinksResolver(allEndpoints, basePath), shouldRegisterLinksMapping(webEndpointProperties, environment, basePath));
}
Also used : ExposableWebEndpoint(org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint) ExposableEndpoint(org.springframework.boot.actuate.endpoint.ExposableEndpoint) ArrayList(java.util.ArrayList) WebFluxEndpointHandlerMapping(org.springframework.boot.actuate.endpoint.web.reactive.WebFluxEndpointHandlerMapping) EndpointLinksResolver(org.springframework.boot.actuate.endpoint.web.EndpointLinksResolver) EndpointMapping(org.springframework.boot.actuate.endpoint.web.EndpointMapping) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnBean(org.springframework.boot.autoconfigure.condition.ConditionalOnBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 3 with ExposableEndpoint

use of org.springframework.boot.actuate.endpoint.ExposableEndpoint in project spring-boot by spring-projects.

the class ReactiveCloudFoundryActuatorAutoConfiguration method cloudFoundryWebFluxEndpointHandlerMapping.

@Bean
public CloudFoundryWebFluxEndpointHandlerMapping cloudFoundryWebFluxEndpointHandlerMapping(ParameterValueMapper parameterMapper, EndpointMediaTypes endpointMediaTypes, WebClient.Builder webClientBuilder, ControllerEndpointsSupplier controllerEndpointsSupplier, ApplicationContext applicationContext) {
    CloudFoundryWebEndpointDiscoverer endpointDiscoverer = new CloudFoundryWebEndpointDiscoverer(applicationContext, parameterMapper, endpointMediaTypes, null, Collections.emptyList(), Collections.emptyList());
    CloudFoundrySecurityInterceptor securityInterceptor = getSecurityInterceptor(webClientBuilder, applicationContext.getEnvironment());
    Collection<ExposableWebEndpoint> webEndpoints = endpointDiscoverer.getEndpoints();
    List<ExposableEndpoint<?>> allEndpoints = new ArrayList<>();
    allEndpoints.addAll(webEndpoints);
    allEndpoints.addAll(controllerEndpointsSupplier.getEndpoints());
    return new CloudFoundryWebFluxEndpointHandlerMapping(new EndpointMapping("/cloudfoundryapplication"), webEndpoints, endpointMediaTypes, getCorsConfiguration(), securityInterceptor, new EndpointLinksResolver(allEndpoints));
}
Also used : CloudFoundryWebEndpointDiscoverer(org.springframework.boot.actuate.autoconfigure.cloudfoundry.CloudFoundryWebEndpointDiscoverer) ExposableWebEndpoint(org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint) ExposableEndpoint(org.springframework.boot.actuate.endpoint.ExposableEndpoint) ArrayList(java.util.ArrayList) EndpointLinksResolver(org.springframework.boot.actuate.endpoint.web.EndpointLinksResolver) EndpointMapping(org.springframework.boot.actuate.endpoint.web.EndpointMapping) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnBean(org.springframework.boot.autoconfigure.condition.ConditionalOnBean) Bean(org.springframework.context.annotation.Bean)

Example 4 with ExposableEndpoint

use of org.springframework.boot.actuate.endpoint.ExposableEndpoint in project spring-boot by spring-projects.

the class CloudFoundryActuatorAutoConfiguration method cloudFoundryWebEndpointServletHandlerMapping.

@Bean
public CloudFoundryWebEndpointServletHandlerMapping cloudFoundryWebEndpointServletHandlerMapping(ParameterValueMapper parameterMapper, EndpointMediaTypes endpointMediaTypes, RestTemplateBuilder restTemplateBuilder, ServletEndpointsSupplier servletEndpointsSupplier, ControllerEndpointsSupplier controllerEndpointsSupplier, ApplicationContext applicationContext) {
    CloudFoundryWebEndpointDiscoverer discoverer = new CloudFoundryWebEndpointDiscoverer(applicationContext, parameterMapper, endpointMediaTypes, null, Collections.emptyList(), Collections.emptyList());
    CloudFoundrySecurityInterceptor securityInterceptor = getSecurityInterceptor(restTemplateBuilder, applicationContext.getEnvironment());
    Collection<ExposableWebEndpoint> webEndpoints = discoverer.getEndpoints();
    List<ExposableEndpoint<?>> allEndpoints = new ArrayList<>();
    allEndpoints.addAll(webEndpoints);
    allEndpoints.addAll(servletEndpointsSupplier.getEndpoints());
    allEndpoints.addAll(controllerEndpointsSupplier.getEndpoints());
    return new CloudFoundryWebEndpointServletHandlerMapping(new EndpointMapping("/cloudfoundryapplication"), webEndpoints, endpointMediaTypes, getCorsConfiguration(), securityInterceptor, new EndpointLinksResolver(allEndpoints));
}
Also used : CloudFoundryWebEndpointDiscoverer(org.springframework.boot.actuate.autoconfigure.cloudfoundry.CloudFoundryWebEndpointDiscoverer) ExposableWebEndpoint(org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint) ExposableEndpoint(org.springframework.boot.actuate.endpoint.ExposableEndpoint) ArrayList(java.util.ArrayList) EndpointLinksResolver(org.springframework.boot.actuate.endpoint.web.EndpointLinksResolver) EndpointMapping(org.springframework.boot.actuate.endpoint.web.EndpointMapping) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnBean(org.springframework.boot.autoconfigure.condition.ConditionalOnBean) Bean(org.springframework.context.annotation.Bean)

Example 5 with ExposableEndpoint

use of org.springframework.boot.actuate.endpoint.ExposableEndpoint in project spring-boot by spring-projects.

the class EndpointRequestTests method excludeByClassShouldNotMatchExcluded.

@Test
void excludeByClassShouldNotMatchExcluded() {
    ServerWebExchangeMatcher matcher = EndpointRequest.toAnyEndpoint().excluding(FooEndpoint.class, BazServletEndpoint.class);
    List<ExposableEndpoint<?>> endpoints = new ArrayList<>();
    endpoints.add(mockEndpoint(EndpointId.of("foo"), "foo"));
    endpoints.add(mockEndpoint(EndpointId.of("bar"), "bar"));
    endpoints.add(mockEndpoint(EndpointId.of("baz"), "baz"));
    PathMappedEndpoints pathMappedEndpoints = new PathMappedEndpoints("/actuator", () -> endpoints);
    assertMatcher(matcher, pathMappedEndpoints).doesNotMatch("/actuator/foo");
    assertMatcher(matcher, pathMappedEndpoints).doesNotMatch("/actuator/baz");
    assertMatcher(matcher).matches("/actuator/bar");
    assertMatcher(matcher).matches("/actuator");
}
Also used : ExposableEndpoint(org.springframework.boot.actuate.endpoint.ExposableEndpoint) ArrayList(java.util.ArrayList) ServerWebExchangeMatcher(org.springframework.security.web.server.util.matcher.ServerWebExchangeMatcher) PathMappedEndpoints(org.springframework.boot.actuate.endpoint.web.PathMappedEndpoints) Test(org.junit.jupiter.api.Test)

Aggregations

ArrayList (java.util.ArrayList)6 ExposableEndpoint (org.springframework.boot.actuate.endpoint.ExposableEndpoint)6 EndpointLinksResolver (org.springframework.boot.actuate.endpoint.web.EndpointLinksResolver)4 EndpointMapping (org.springframework.boot.actuate.endpoint.web.EndpointMapping)4 ExposableWebEndpoint (org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint)4 ConditionalOnBean (org.springframework.boot.autoconfigure.condition.ConditionalOnBean)4 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)4 Bean (org.springframework.context.annotation.Bean)4 Test (org.junit.jupiter.api.Test)2 CloudFoundryWebEndpointDiscoverer (org.springframework.boot.actuate.autoconfigure.cloudfoundry.CloudFoundryWebEndpointDiscoverer)2 PathMappedEndpoints (org.springframework.boot.actuate.endpoint.web.PathMappedEndpoints)2 WebFluxEndpointHandlerMapping (org.springframework.boot.actuate.endpoint.web.reactive.WebFluxEndpointHandlerMapping)1 WebMvcEndpointHandlerMapping (org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping)1 ServerWebExchangeMatcher (org.springframework.security.web.server.util.matcher.ServerWebExchangeMatcher)1 RequestMatcher (org.springframework.security.web.util.matcher.RequestMatcher)1