Java Code Examples for org.springframework.mock.web.mockhttpservletrequest#setRemoteUser()
The following examples show how to use
org.springframework.mock.web.mockhttpservletrequest#setRemoteUser() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HttpMockServiceImpl.java From AnyMock with Apache License 2.0 | 6 votes |
private MockHttpServletRequest buildMockRequest(HttpServletRequest request) { MockHttpServletRequest mockRequest = new MockHttpServletRequest(); mockRequest.setParameters(request.getParameterMap()); Enumeration headerNames = request.getHeaderNames(); while (headerNames.hasMoreElements()) { String key = (String)headerNames.nextElement(); mockRequest.addHeader(key, request.getHeader(key)); } mockRequest.setMethod(request.getMethod()); mockRequest.setRequestURI(request.getRequestURI()); mockRequest.setRemoteAddr(request.getRemoteAddr()); mockRequest.setRemoteHost(request.getRemoteHost()); mockRequest.setRemotePort(request.getRemotePort()); mockRequest.setRemoteUser(request.getRemoteUser()); mockRequest.setAttribute(BODY, request.getAttribute(BODY)); return mockRequest; }
Example 2
Source File: ClearPassControllerTests.java From springboot-shiro-cas-mybatis with MIT License | 5 votes |
@Test public void verifyClearPassWithUsernameMissingInCache() throws Exception { final ClearPassController controller = new ClearPassController(this.map); final MockHttpServletRequest req = new MockHttpServletRequest(); req.setRemoteUser("casuser"); final ModelAndView mv = controller.handleRequestInternal(req, new MockHttpServletResponse()); assertEquals(mv.getViewName(), ClearPassController.DEFAULT_SERVICE_FAILURE_VIEW_NAME); assertTrue(mv.getModel().containsKey(ClearPassController.MODEL_FAILURE_DESCRIPTION)); }
Example 3
Source File: ClearPassControllerTests.java From springboot-shiro-cas-mybatis with MIT License | 5 votes |
@Test public void verifyClearPassSuccess() throws Exception { final ClearPassController controller = new ClearPassController(this.map); final MockHttpServletRequest req = new MockHttpServletRequest(); req.setRemoteUser("casuser"); this.map.put("casuser", "password"); final ModelAndView mv = controller.handleRequestInternal(req, new MockHttpServletResponse()); assertEquals(mv.getViewName(), ClearPassController.DEFAULT_SERVICE_SUCCESS_VIEW_NAME); assertTrue(mv.getModel().containsKey(ClearPassController.MODEL_CLEARPASS)); assertTrue(mv.getModel().containsValue("password")); }
Example 4
Source File: PrincipalFromRequestRemoteUserNonInteractiveCredentialsActionTests.java From springboot-shiro-cas-mybatis with MIT License | 5 votes |
@Test public void verifyRemoteUserExists() throws Exception { final MockHttpServletRequest request = new MockHttpServletRequest(); request.setRemoteUser("test"); final MockRequestContext context = new MockRequestContext(); context.setExternalContext(new ServletExternalContext( new MockServletContext(), request, new MockHttpServletResponse())); assertEquals("success", this.action.execute(context).getId()); }
Example 5
Source File: PrincipalFromRequestRemoteUserNonInteractiveCredentialsActionTests.java From cas4.0.x-server-wechat with Apache License 2.0 | 5 votes |
@Test public void testRemoteUserExists() throws Exception { final MockHttpServletRequest request = new MockHttpServletRequest(); request.setRemoteUser("test"); final MockRequestContext context = new MockRequestContext(); context.setExternalContext(new ServletExternalContext( new MockServletContext(), request, new MockHttpServletResponse())); assertEquals("success", this.action.execute(context).getId()); }
Example 6
Source File: RequestLoggingFilterTest.java From herd with Apache License 2.0 | 5 votes |
private MockHttpServletRequest createServletRequest() { MockHttpServletRequest request = new MockHttpServletRequest(null, "/test"); request.setQueryString("param=value"); request.setMethod("POST"); MockHttpSession session = new MockHttpSession(); request.setContent(PAYLOAD_CONTENT.getBytes()); request.setSession(session); request.setRemoteUser("Test Remote User"); return request; }