Search in sources :

Example 56 with RequestMatcher

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

the class EndpointRequestTests method excludeLinksShouldNotMatchBasePath.

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

Example 57 with RequestMatcher

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

the class PathRequestTests method toH2ConsoleWhenManagementContextShouldNeverMatch.

@Test
void toH2ConsoleWhenManagementContextShouldNeverMatch() {
    RequestMatcher matcher = PathRequest.toH2Console();
    assertMatcher(matcher, "management").doesNotMatch("/h2-console");
    assertMatcher(matcher, "management").doesNotMatch("/h2-console/subpath");
    assertMatcher(matcher, "management").doesNotMatch("/js/file.js");
}
Also used : RequestMatcher(org.springframework.security.web.util.matcher.RequestMatcher) Test(org.junit.jupiter.api.Test)

Example 58 with RequestMatcher

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

the class PathRequestTests method toH2ConsoleShouldMatchH2ConsolePath.

@Test
void toH2ConsoleShouldMatchH2ConsolePath() {
    RequestMatcher matcher = PathRequest.toH2Console();
    assertMatcher(matcher).matches("/h2-console");
    assertMatcher(matcher).matches("/h2-console/subpath");
    assertMatcher(matcher).doesNotMatch("/js/file.js");
}
Also used : RequestMatcher(org.springframework.security.web.util.matcher.RequestMatcher) Test(org.junit.jupiter.api.Test)

Example 59 with RequestMatcher

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

the class StaticResourceRequestTests method atCommonLocationsWhenManagementContextShouldNeverMatch.

@Test
void atCommonLocationsWhenManagementContextShouldNeverMatch() {
    RequestMatcher matcher = this.resourceRequest.atCommonLocations();
    assertMatcher(matcher, "management").doesNotMatch("/css/file.css");
    assertMatcher(matcher, "management").doesNotMatch("/js/file.js");
    assertMatcher(matcher, "management").doesNotMatch("/images/file.css");
    assertMatcher(matcher, "management").doesNotMatch("/webjars/file.css");
    assertMatcher(matcher, "management").doesNotMatch("/foo/favicon.ico");
}
Also used : RequestMatcher(org.springframework.security.web.util.matcher.RequestMatcher) Test(org.junit.jupiter.api.Test)

Example 60 with RequestMatcher

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

the class StaticResourceRequestTests method atLocationShouldMatchLocation.

@Test
void atLocationShouldMatchLocation() {
    RequestMatcher matcher = this.resourceRequest.at(StaticResourceLocation.CSS);
    assertMatcher(matcher).matches("/css/file.css");
    assertMatcher(matcher).doesNotMatch("/js/file.js");
}
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