Search in sources :

Example 41 with MockHttpServletRequest

use of org.springframework.mock.web.MockHttpServletRequest in project spring-security by spring-projects.

the class AccessControlListTagTests method setup.

@Before
@SuppressWarnings("rawtypes")
public void setup() {
    SecurityContextHolder.getContext().setAuthentication(bob);
    tag = new AccessControlListTag();
    WebApplicationContext ctx = mock(WebApplicationContext.class);
    pe = mock(PermissionEvaluator.class);
    Map beanMap = new HashMap();
    beanMap.put("pe", pe);
    when(ctx.getBeansOfType(PermissionEvaluator.class)).thenReturn(beanMap);
    MockServletContext servletCtx = new MockServletContext();
    servletCtx.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ctx);
    pageContext = new MockPageContext(servletCtx, new MockHttpServletRequest(), new MockHttpServletResponse());
    tag.setPageContext(pageContext);
}
Also used : PermissionEvaluator(org.springframework.security.access.PermissionEvaluator) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) MockPageContext(org.springframework.mock.web.MockPageContext) MockServletContext(org.springframework.mock.web.MockServletContext) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) WebApplicationContext(org.springframework.web.context.WebApplicationContext)

Example 42 with MockHttpServletRequest

use of org.springframework.mock.web.MockHttpServletRequest in project spring-security by spring-projects.

the class SecurityMockMvcRequestPostProcessorsDigestTests method digestWithFilterCustomRealm.

@Test
public void digestWithFilterCustomRealm() throws Exception {
    String username = "admin";
    entryPoint.setRealmName("Custom");
    MockHttpServletRequest postProcessedRequest = digest(username).realm(entryPoint.getRealmName()).postProcessRequest(request);
    assertThat(extractUser()).isEqualTo(username);
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Test(org.junit.Test)

Example 43 with MockHttpServletRequest

use of org.springframework.mock.web.MockHttpServletRequest in project spring-security by spring-projects.

the class SecurityMockMvcRequestPostProcessorsSecurityContextTests method setup.

@Before
public void setup() {
    request = new MockHttpServletRequest();
    mockWebTestUtils();
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Before(org.junit.Before)

Example 44 with MockHttpServletRequest

use of org.springframework.mock.web.MockHttpServletRequest in project spring-security by spring-projects.

the class SecurityMockMvcRequestPostProcessorsUserDetailsTests method setup.

@Before
public void setup() {
    request = new MockHttpServletRequest();
    mockWebTestUtils();
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Before(org.junit.Before)

Example 45 with MockHttpServletRequest

use of org.springframework.mock.web.MockHttpServletRequest in project spring-security by spring-projects.

the class SecurityMockMvcRequestPostProcessorsUserTests method setup.

@Before
public void setup() {
    request = new MockHttpServletRequest();
    mockWebTestUtils();
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Before(org.junit.Before)

Aggregations

MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1136 Test (org.junit.Test)882 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)605 Before (org.junit.Before)107 MockFilterChain (org.springframework.mock.web.MockFilterChain)93 MockServletContext (org.springframework.mock.web.MockServletContext)82 FilterChain (javax.servlet.FilterChain)79 Authentication (org.springframework.security.core.Authentication)70 HttpServletRequest (javax.servlet.http.HttpServletRequest)62 ServletExternalContext (org.springframework.webflow.context.servlet.ServletExternalContext)60 MockRequestContext (org.springframework.webflow.test.MockRequestContext)53 MockHttpSession (org.springframework.mock.web.MockHttpSession)51 HttpServletResponse (javax.servlet.http.HttpServletResponse)48 Cookie (javax.servlet.http.Cookie)46 HashMap (java.util.HashMap)39 TicketGrantingTicket (org.apereo.cas.ticket.TicketGrantingTicket)33 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)32 ModelAndView (org.springframework.web.servlet.ModelAndView)32 RegisteredService (org.apereo.cas.services.RegisteredService)30 MockPortletWindowId (org.apereo.portal.mock.portlet.om.MockPortletWindowId)30