Add FilterSecurityInterceptor once per request test

Issue: gh-4997
This commit is contained in:
Rob Winch 2018-02-08 17:08:59 -06:00
parent 40a1281c66
commit fcf967687b
1 changed files with 13 additions and 0 deletions

View File

@ -21,6 +21,7 @@ import static org.mockito.Mockito.*;
import org.junit.*;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.mock.web.MockFilterChain;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.security.access.AccessDecisionManager;
@ -178,6 +179,18 @@ public class FilterSecurityInterceptorTests {
assertThat(SecurityContextHolder.getContext().getAuthentication()).isSameAs(token);
}
@Test
// gh-4997
public void doFilterWhenObserveOncePerRequestThenAttributeNotSet() throws Exception {
this.interceptor.setObserveOncePerRequest(false);
MockHttpServletResponse response = new MockHttpServletResponse();
MockHttpServletRequest request = new MockHttpServletRequest();
this.interceptor.doFilter(request, response, new MockFilterChain());
assertThat(request.getAttributeNames().hasMoreElements()).isFalse();
}
private FilterInvocation createinvocation() {
MockHttpServletResponse response = new MockHttpServletResponse();
MockHttpServletRequest request = new MockHttpServletRequest();