Search in sources :

Example 1 with PathMappedEndpoints

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

the class EndpointRequestTests method noEndpointPathsBeansShouldNeverMatch.

@Test
void noEndpointPathsBeansShouldNeverMatch() {
    ServerWebExchangeMatcher matcher = EndpointRequest.toAnyEndpoint();
    assertMatcher(matcher, (PathMappedEndpoints) null).doesNotMatch("/actuator/foo");
    assertMatcher(matcher, (PathMappedEndpoints) null).doesNotMatch("/actuator/bar");
}
Also used : ServerWebExchangeMatcher(org.springframework.security.web.server.util.matcher.ServerWebExchangeMatcher) PathMappedEndpoints(org.springframework.boot.actuate.endpoint.web.PathMappedEndpoints) Test(org.junit.jupiter.api.Test)

Example 2 with PathMappedEndpoints

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

the class EndpointRequestTests method noEndpointPathsBeansShouldNeverMatch.

@Test
void noEndpointPathsBeansShouldNeverMatch() {
    RequestMatcher matcher = EndpointRequest.toAnyEndpoint();
    assertMatcher(matcher, (PathMappedEndpoints) null).doesNotMatch("/actuator/foo");
    assertMatcher(matcher, (PathMappedEndpoints) null).doesNotMatch("/actuator/bar");
}
Also used : RequestMatcher(org.springframework.security.web.util.matcher.RequestMatcher) PathMappedEndpoints(org.springframework.boot.actuate.endpoint.web.PathMappedEndpoints) Test(org.junit.jupiter.api.Test)

Example 3 with PathMappedEndpoints

use of org.springframework.boot.actuate.endpoint.web.PathMappedEndpoints 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 4 with PathMappedEndpoints

use of org.springframework.boot.actuate.endpoint.web.PathMappedEndpoints 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

Test (org.junit.jupiter.api.Test)4 PathMappedEndpoints (org.springframework.boot.actuate.endpoint.web.PathMappedEndpoints)4 ArrayList (java.util.ArrayList)2 ExposableEndpoint (org.springframework.boot.actuate.endpoint.ExposableEndpoint)2 ServerWebExchangeMatcher (org.springframework.security.web.server.util.matcher.ServerWebExchangeMatcher)2 RequestMatcher (org.springframework.security.web.util.matcher.RequestMatcher)2