當前位置: 首頁>>代碼示例>>Java>>正文


Java MockHttpServletRequest.setLocalAddr方法代碼示例

本文整理匯總了Java中org.springframework.mock.web.MockHttpServletRequest.setLocalAddr方法的典型用法代碼示例。如果您正苦於以下問題:Java MockHttpServletRequest.setLocalAddr方法的具體用法?Java MockHttpServletRequest.setLocalAddr怎麽用?Java MockHttpServletRequest.setLocalAddr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.mock.web.MockHttpServletRequest的用法示例。


在下文中一共展示了MockHttpServletRequest.setLocalAddr方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: verifyTgtToSet

import org.springframework.mock.web.MockHttpServletRequest; //導入方法依賴的package包/類
@Test
public void verifyTgtToSet() throws Exception {
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRemoteAddr(LOCALHOST_IP);
    request.setLocalAddr(LOCALHOST_IP);
    ClientInfoHolder.setClientInfo(new ClientInfo(request));

    final MockHttpServletResponse response = new MockHttpServletResponse();
    request.addHeader("User-Agent", "Test");
    final TicketGrantingTicket tgt = mock(TicketGrantingTicket.class);
    when(tgt.getId()).thenReturn(TEST_STRING);

    WebUtils.putTicketGrantingTicketInScopes(this.context, tgt);
    this.context.setExternalContext(new ServletExternalContext(new MockServletContext(),
            request, response));

    assertEquals(SUCCESS, this.action.execute(this.context).getId());
    request.setCookies(response.getCookies());
    assertEquals(tgt.getId(), this.ticketGrantingTicketCookieGenerator.retrieveCookieValue(request));
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:21,代碼來源:SendTicketGrantingTicketActionTests.java

示例2: verifyTgtToSetRemovingOldTgt

import org.springframework.mock.web.MockHttpServletRequest; //導入方法依賴的package包/類
@Test
public void verifyTgtToSetRemovingOldTgt() throws Exception {
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRemoteAddr(LOCALHOST_IP);
    request.setLocalAddr(LOCALHOST_IP);
    ClientInfoHolder.setClientInfo(new ClientInfo(request));

    final MockHttpServletResponse response = new MockHttpServletResponse();
    request.addHeader("User-Agent", "Test");

    final TicketGrantingTicket tgt = mock(TicketGrantingTicket.class);
    when(tgt.getId()).thenReturn(TEST_STRING);

    request.setCookies(new Cookie("TGT", "test5"));
    WebUtils.putTicketGrantingTicketInScopes(this.context, tgt);
    this.context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));

    assertEquals(SUCCESS, this.action.execute(this.context).getId());
    request.setCookies(response.getCookies());
    assertEquals(tgt.getId(), this.ticketGrantingTicketCookieGenerator.retrieveCookieValue(request));
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:22,代碼來源:SendTicketGrantingTicketActionTests.java

示例3: verifyTestWhenAuthnEventsFoundForUser

import org.springframework.mock.web.MockHttpServletRequest; //導入方法依賴的package包/類
@Test
public void verifyTestWhenAuthnEventsFoundForUser() {
    final Authentication authentication = CoreAuthenticationTestUtils.getAuthentication("casuser");
    final RegisteredService service = RegisteredServiceTestUtils.getRegisteredService("test");
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRemoteAddr("107.181.69.221");
    request.setLocalAddr("127.0.0.1");
    ClientInfoHolder.setClientInfo(new ClientInfo(request));
    final AuthenticationRiskScore score = authenticationRiskEvaluator.eval(authentication, service, request);
    assertTrue(score.isHighestRisk());
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:12,代碼來源:GeoLocationAuthenticationRequestRiskCalculatorTests.java

示例4: verifyTestWhenAuthnEventsFoundForUser

import org.springframework.mock.web.MockHttpServletRequest; //導入方法依賴的package包/類
@Test
public void verifyTestWhenAuthnEventsFoundForUser() {
    final Authentication authentication = CoreAuthenticationTestUtils.getAuthentication("casuser");
    final RegisteredService service = RegisteredServiceTestUtils.getRegisteredService("test");
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRemoteAddr("107.181.69.221");
    request.setLocalAddr("127.0.0.1");
    ClientInfoHolder.setClientInfo(new ClientInfo(request));
    final AuthenticationRiskScore score = authenticationRiskEvaluator.eval(authentication, service, request);
    assertTrue(score.isRiskGreaterThan(casProperties.getAuthn().getAdaptive().getRisk().getThreshold()));
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:12,代碼來源:IpAddressAuthenticationRequestRiskCalculatorTests.java

示例5: verifyTestWhenAuthnEventsFoundForUser

import org.springframework.mock.web.MockHttpServletRequest; //導入方法依賴的package包/類
@Test
public void verifyTestWhenAuthnEventsFoundForUser() {
    final Authentication authentication = CoreAuthenticationTestUtils.getAuthentication("casuser");
    final RegisteredService service = RegisteredServiceTestUtils.getRegisteredService("test");
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.addHeader(WebUtils.USER_AGENT_HEADER, "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)");

    request.setRemoteAddr("107.181.69.221");
    request.setLocalAddr("127.0.0.1");
    ClientInfoHolder.setClientInfo(new ClientInfo(request));
    final AuthenticationRiskScore score = authenticationRiskEvaluator.eval(authentication, service, request);
    assertTrue(score.isRiskGreaterThan(casProperties.getAuthn().getAdaptive().getRisk().getThreshold()));
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:14,代碼來源:UserAgentAuthenticationRequestRiskCalculatorTests.java

示例6: setUp

import org.springframework.mock.web.MockHttpServletRequest; //導入方法依賴的package包/類
@BeforeClass
public static void setUp() {
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRemoteAddr("1.2.3.4");
    request.setLocalAddr("7.8.9.0");
    ClientInfoHolder.setClientInfo(new ClientInfo(request));
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:8,代碼來源:CasSupportJdbcAuditConfigurationTests.java

示例7: setUp

import org.springframework.mock.web.MockHttpServletRequest; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRemoteAddr(IP_ADDRESS);
    request.setLocalAddr(IP_ADDRESS);
    ClientInfoHolder.setClientInfo(new ClientInfo(request));
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:8,代碼來源:AbstractThrottledSubmissionHandlerInterceptorAdapterTests.java


注:本文中的org.springframework.mock.web.MockHttpServletRequest.setLocalAddr方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。