use of org.springframework.mock.web.MockHttpServletRequest in project cas by apereo.
the class DateTimeAuthenticationRequestRiskCalculatorTests method verifyTestWhenNoAuthnEventsFoundForUser.
@Test
public void verifyTestWhenNoAuthnEventsFoundForUser() {
final Authentication authentication = CoreAuthenticationTestUtils.getAuthentication("datetimeperson");
final RegisteredService service = RegisteredServiceTestUtils.getRegisteredService("test");
final MockHttpServletRequest request = new MockHttpServletRequest();
final AuthenticationRiskScore score = authenticationRiskEvaluator.eval(authentication, service, request);
assertTrue(score.isHighestRisk());
}
use of org.springframework.mock.web.MockHttpServletRequest in project cas by apereo.
the class GeoLocationAuthenticationRequestRiskCalculatorTests method verifyTestWhenAuthnEventsFoundForUser.
@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());
}
use of org.springframework.mock.web.MockHttpServletRequest in project cas by apereo.
the class IpAddressAuthenticationRequestRiskCalculatorTests method verifyTestWhenNoAuthnEventsFoundForUser.
@Test
public void verifyTestWhenNoAuthnEventsFoundForUser() {
final Authentication authentication = CoreAuthenticationTestUtils.getAuthentication("nobody");
final RegisteredService service = RegisteredServiceTestUtils.getRegisteredService("test");
final MockHttpServletRequest request = new MockHttpServletRequest();
final AuthenticationRiskScore score = authenticationRiskEvaluator.eval(authentication, service, request);
assertTrue(score.isHighestRisk());
}
use of org.springframework.mock.web.MockHttpServletRequest in project cas by apereo.
the class IpAddressAuthenticationRequestRiskCalculatorTests method verifyTestWhenAuthnEventsFoundForUser.
@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()));
}
use of org.springframework.mock.web.MockHttpServletRequest in project cas by apereo.
the class UserAgentAuthenticationRequestRiskCalculatorTests method verifyTestWhenAuthnEventsFoundForUser.
@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()));
}
Aggregations