use of org.springframework.security.web.DefaultSecurityFilterChain in project spring-security by spring-projects.
the class NamespaceHttpTests method configureWhenRequestMatcherProvidedThenRequestMatcherUsed.
// http@request-matcher-ref
@Test
public void configureWhenRequestMatcherProvidedThenRequestMatcherUsed() {
this.spring.register(RequestMatcherRefConfig.class).autowire();
FilterChainProxy filterChainProxy = this.spring.getContext().getBean(FilterChainProxy.class);
assertThat(filterChainProxy.getFilterChains().get(0)).isInstanceOf(DefaultSecurityFilterChain.class);
DefaultSecurityFilterChain securityFilterChain = (DefaultSecurityFilterChain) filterChainProxy.getFilterChains().get(0);
assertThat(securityFilterChain.getRequestMatcher()).isInstanceOf(RequestMatcherRefConfig.MyRequestMatcher.class);
}
use of org.springframework.security.web.DefaultSecurityFilterChain in project spring-security by spring-projects.
the class NamespaceHttpTests method configureWhenAntPatternMatchingThenAntPathRequestMatcherUsed.
// http@request-matcher-ref ant
@Test
public void configureWhenAntPatternMatchingThenAntPathRequestMatcherUsed() {
this.spring.register(RequestMatcherAntConfig.class).autowire();
FilterChainProxy filterChainProxy = this.spring.getContext().getBean(FilterChainProxy.class);
assertThat(filterChainProxy.getFilterChains().get(0)).isInstanceOf(DefaultSecurityFilterChain.class);
DefaultSecurityFilterChain securityFilterChain = (DefaultSecurityFilterChain) filterChainProxy.getFilterChains().get(0);
assertThat(securityFilterChain.getRequestMatcher()).isInstanceOf(AntPathRequestMatcher.class);
}
use of org.springframework.security.web.DefaultSecurityFilterChain in project spring-security by spring-projects.
the class NamespaceHttpTests method configureWhenRegexPatternMatchingThenRegexRequestMatcherUsed.
// http@request-matcher-ref regex
@Test
public void configureWhenRegexPatternMatchingThenRegexRequestMatcherUsed() {
this.spring.register(RequestMatcherRegexConfig.class).autowire();
FilterChainProxy filterChainProxy = this.spring.getContext().getBean(FilterChainProxy.class);
assertThat(filterChainProxy.getFilterChains().get(0)).isInstanceOf(DefaultSecurityFilterChain.class);
DefaultSecurityFilterChain securityFilterChain = (DefaultSecurityFilterChain) filterChainProxy.getFilterChains().get(0);
assertThat(securityFilterChain.getRequestMatcher()).isInstanceOf(RegexRequestMatcher.class);
}
use of org.springframework.security.web.DefaultSecurityFilterChain in project spring-security by spring-projects.
the class SecurityMockMvcRequestPostProcessorsJwtTests method setup.
@BeforeEach
public void setup() {
SecurityContextPersistenceFilter filter = new SecurityContextPersistenceFilter(this.repository);
MockServletContext servletContext = new MockServletContext();
servletContext.setAttribute(BeanIds.SPRING_SECURITY_FILTER_CHAIN, new FilterChainProxy(new DefaultSecurityFilterChain(AnyRequestMatcher.INSTANCE, filter)));
this.request = new MockHttpServletRequest(servletContext);
WebTestUtils.setSecurityContextRepository(this.request, this.repository);
}
use of org.springframework.security.web.DefaultSecurityFilterChain in project spring-security by spring-projects.
the class WebTestUtilsTests method findFilterExplicitWithSecurityFilterInContext.
@Test
public void findFilterExplicitWithSecurityFilterInContext() {
loadConfig(SecurityConfigWithDefaults.class);
CsrfFilter toFind = new CsrfFilter(new HttpSessionCsrfTokenRepository());
FilterChainProxy springSecurityFilterChain = new FilterChainProxy(new DefaultSecurityFilterChain(AnyRequestMatcher.INSTANCE, toFind));
this.request.getServletContext().setAttribute(BeanIds.SPRING_SECURITY_FILTER_CHAIN, springSecurityFilterChain);
assertThat(WebTestUtils.findFilter(this.request, toFind.getClass())).isSameAs(toFind);
}
Aggregations