Search in sources :

Example 21 with ServerWebExchangeMatcher

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

the class StaticResourceRequestTests method atCommonLocationsWithExcludeShouldNotMatchExcluded.

@Test
void atCommonLocationsWithExcludeShouldNotMatchExcluded() {
    ServerWebExchangeMatcher matcher = this.resourceRequest.atCommonLocations().excluding(StaticResourceLocation.CSS);
    assertMatcher(matcher).doesNotMatch("/css/file.css");
    assertMatcher(matcher).matches("/js/file.js");
}
Also used : ServerWebExchangeMatcher(org.springframework.security.web.server.util.matcher.ServerWebExchangeMatcher) Test(org.junit.jupiter.api.Test)

Example 22 with ServerWebExchangeMatcher

use of org.springframework.security.web.server.util.matcher.ServerWebExchangeMatcher 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)

Example 23 with ServerWebExchangeMatcher

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

the class EndpointRequestTests method excludeByIdShouldNotMatchLinksIfExcluded.

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

Example 24 with ServerWebExchangeMatcher

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

the class EndpointRequestTests method excludeLinksShouldNotMatchBasePathIfEmptyAndExcluded.

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

Example 25 with ServerWebExchangeMatcher

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

the class EndpointRequestTests method toEndpointClassShouldMatchEndpointPath.

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

Aggregations

ServerWebExchangeMatcher (org.springframework.security.web.server.util.matcher.ServerWebExchangeMatcher)38 Test (org.junit.jupiter.api.Test)35 MockServerWebExchange (org.springframework.mock.web.server.MockServerWebExchange)8 ServerWebExchange (org.springframework.web.server.ServerWebExchange)6 Collections (java.util.Collections)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)3 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)3 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)3 BDDMockito.given (org.mockito.BDDMockito.given)3 Mockito.mock (org.mockito.Mockito.mock)3 Mockito.spy (org.mockito.Mockito.spy)3 Mockito.verify (org.mockito.Mockito.verify)3 Answer (org.mockito.stubbing.Answer)3 WebDriver (org.openqa.selenium.WebDriver)3 Autowired (org.springframework.beans.factory.annotation.Autowired)3 ApplicationContext (org.springframework.context.ApplicationContext)3 Bean (org.springframework.context.annotation.Bean)3 Configuration (org.springframework.context.annotation.Configuration)3