Search in sources :

Example 26 with RequestMatcher

use of org.springframework.security.web.util.matcher.RequestMatcher in project spring-boot by spring-projects.

the class EndpointRequestTests method excludeByClassShouldNotMatchLinksIfExcluded.

@Test
void excludeByClassShouldNotMatchLinksIfExcluded() {
    RequestMatcher matcher = EndpointRequest.toAnyEndpoint().excludingLinks().excluding(FooEndpoint.class);
    assertMatcher(matcher).doesNotMatch("/actuator/foo");
    assertMatcher(matcher).doesNotMatch("/actuator");
}
Also used : RequestMatcher(org.springframework.security.web.util.matcher.RequestMatcher) Test(org.junit.jupiter.api.Test)

Example 27 with RequestMatcher

use of org.springframework.security.web.util.matcher.RequestMatcher in project spring-boot by spring-projects.

the class EndpointRequestTests method toEndpointClassShouldMatchEndpointPath.

@Test
void toEndpointClassShouldMatchEndpointPath() {
    RequestMatcher matcher = EndpointRequest.to(FooEndpoint.class);
    assertMatcher(matcher).matches("/actuator/foo");
}
Also used : RequestMatcher(org.springframework.security.web.util.matcher.RequestMatcher) Test(org.junit.jupiter.api.Test)

Example 28 with RequestMatcher

use of org.springframework.security.web.util.matcher.RequestMatcher in project spring-boot by spring-projects.

the class EndpointRequestTests method toAnyEndpointWhenDispatcherServletPathProviderNotAvailableUsesEmptyPath.

@Test
void toAnyEndpointWhenDispatcherServletPathProviderNotAvailableUsesEmptyPath() {
    RequestMatcher matcher = EndpointRequest.toAnyEndpoint();
    assertMatcher(matcher, "/actuator").matches("/actuator/foo");
    assertMatcher(matcher, "/actuator").matches("/actuator/bar");
    assertMatcher(matcher, "/actuator").matches("/actuator");
    assertMatcher(matcher, "/actuator").doesNotMatch("/actuator/baz");
}
Also used : RequestMatcher(org.springframework.security.web.util.matcher.RequestMatcher) Test(org.junit.jupiter.api.Test)

Example 29 with RequestMatcher

use of org.springframework.security.web.util.matcher.RequestMatcher 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 30 with RequestMatcher

use of org.springframework.security.web.util.matcher.RequestMatcher in project spring-boot by spring-projects.

the class EndpointRequestTests method excludeByIdShouldNotMatchExcluded.

@Test
void excludeByIdShouldNotMatchExcluded() {
    RequestMatcher matcher = EndpointRequest.toAnyEndpoint().excluding("foo");
    assertMatcher(matcher).doesNotMatch("/actuator/foo");
    assertMatcher(matcher).matches("/actuator/bar");
    assertMatcher(matcher).matches("/actuator");
}
Also used : RequestMatcher(org.springframework.security.web.util.matcher.RequestMatcher) Test(org.junit.jupiter.api.Test)

Aggregations

RequestMatcher (org.springframework.security.web.util.matcher.RequestMatcher)85 Test (org.junit.jupiter.api.Test)40 AntPathRequestMatcher (org.springframework.security.web.util.matcher.AntPathRequestMatcher)27 LinkedHashMap (java.util.LinkedHashMap)16 AndRequestMatcher (org.springframework.security.web.util.matcher.AndRequestMatcher)14 NegatedRequestMatcher (org.springframework.security.web.util.matcher.NegatedRequestMatcher)12 RequestHeaderRequestMatcher (org.springframework.security.web.util.matcher.RequestHeaderRequestMatcher)12 ArrayList (java.util.ArrayList)11 AuthenticationEntryPoint (org.springframework.security.web.AuthenticationEntryPoint)10 OrRequestMatcher (org.springframework.security.web.util.matcher.OrRequestMatcher)10 MediaTypeRequestMatcher (org.springframework.security.web.util.matcher.MediaTypeRequestMatcher)9 Collection (java.util.Collection)8 HttpServletRequest (javax.servlet.http.HttpServletRequest)7 ConfigAttribute (org.springframework.security.access.ConfigAttribute)7 AnyRequestMatcher (org.springframework.security.web.util.matcher.AnyRequestMatcher)7 HttpServletResponse (javax.servlet.http.HttpServletResponse)6 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)6 DelegatingAuthenticationEntryPoint (org.springframework.security.web.authentication.DelegatingAuthenticationEntryPoint)6 ContentNegotiationStrategy (org.springframework.web.accept.ContentNegotiationStrategy)6 HeaderContentNegotiationStrategy (org.springframework.web.accept.HeaderContentNegotiationStrategy)6