use of org.springframework.mock.web.MockFilterChain in project spring-boot by spring-projects.
the class ErrorPageFilterTests method exceptionErrorWithCommittedResponse.
@Test
public void exceptionErrorWithCommittedResponse() throws Exception {
this.filter.addErrorPages(new ErrorPage(RuntimeException.class, "/500"));
this.chain = new MockFilterChain() {
@Override
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
super.doFilter(request, response);
response.flushBuffer();
throw new RuntimeException("BAD");
}
};
this.filter.doFilter(this.request, this.response, this.chain);
assertThat(this.response.getForwardedUrl()).isNull();
}
use of org.springframework.mock.web.MockFilterChain in project spring-security by spring-projects.
the class NamespaceHttpBasicTests method setup.
@Before
public void setup() {
this.request = new MockHttpServletRequest();
this.request.setMethod("GET");
this.response = new MockHttpServletResponse();
this.chain = new MockFilterChain();
}
use of org.springframework.mock.web.MockFilterChain in project spring-security by spring-projects.
the class GrantedAuthorityDefaultsJcTests method setup.
@Before
public void setup() {
setup("USER");
request = new MockHttpServletRequest();
request.setMethod("GET");
response = new MockHttpServletResponse();
chain = new MockFilterChain();
}
use of org.springframework.mock.web.MockFilterChain in project spring-security by spring-projects.
the class GrantedAuthorityDefaultsJcTests method doFilterIsUserInRole.
// SEC-2926
@Test
public void doFilterIsUserInRole() throws Exception {
SecurityContext context = SecurityContextHolder.getContext();
request.getSession().setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY, context);
chain = new MockFilterChain() {
@Override
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
HttpServletRequest httpRequest = (HttpServletRequest) request;
assertThat(httpRequest.isUserInRole("USER")).isTrue();
assertThat(httpRequest.isUserInRole("INVALID")).isFalse();
super.doFilter(request, response);
}
};
springSecurityFilterChain.doFilter(request, response, chain);
assertThat(chain.getRequest()).isNotNull();
}
use of org.springframework.mock.web.MockFilterChain in project spring-security by spring-projects.
the class GrantedAuthorityDefaultsXmlTests method setup.
@Before
public void setup() {
setup("USER");
request = new MockHttpServletRequest();
request.setMethod("GET");
response = new MockHttpServletResponse();
chain = new MockFilterChain();
}
Aggregations