use of org.springframework.security.config.test.SpringTestContext in project spring-security by spring-projects.
the class AccessDeniedConfigTests method configureWhenAccessDeniedHandlerUsesPathAndRefThenException.
@Test
public void configureWhenAccessDeniedHandlerUsesPathAndRefThenException() {
SpringTestContext context = this.spring.configLocations(this.xml("UsesPathAndRef"));
assertThatExceptionOfType(BeanDefinitionParsingException.class).isThrownBy(() -> context.autowire()).withMessageContaining("attribute error-page cannot be used together with the 'ref' attribute");
}
use of org.springframework.security.config.test.SpringTestContext in project spring-security by spring-projects.
the class CsrfConfigTests method requestWhenUsingCustomRequestMatcherConfiguredThenAppliesAccordingly.
@Test
public void requestWhenUsingCustomRequestMatcherConfiguredThenAppliesAccordingly() throws Exception {
SpringTestContext context = this.spring.configLocations(this.xml("shared-controllers"), this.xml("WithRequestMatcher"), this.xml("mock-request-matcher"));
context.autowire();
RequestMatcher matcher = context.getContext().getBean(RequestMatcher.class);
given(matcher.matches(any(HttpServletRequest.class))).willReturn(false);
// @formatter:off
this.mvc.perform(post("/ok")).andExpect(status().isOk());
// @formatter:on
given(matcher.matches(any(HttpServletRequest.class))).willReturn(true);
// @formatter:off
this.mvc.perform(get("/ok")).andExpect(status().isForbidden());
// @formatter:on
}
use of org.springframework.security.config.test.SpringTestContext in project spring-security by spring-projects.
the class AccessDeniedConfigTests method configureWhenAccessDeniedHandlerIsMissingLeadingSlashThenException.
@Test
public void configureWhenAccessDeniedHandlerIsMissingLeadingSlashThenException() {
SpringTestContext context = this.spring.configLocations(this.xml("NoLeadingSlash"));
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() -> context.autowire()).withMessageContaining("errorPage must begin with '/'");
}
Aggregations