use of org.apereo.inspektr.common.web.ClientInfo in project cas by apereo.
the class InitPasswordResetActionTests method verifyAction.
@Test
public void verifyAction() throws Exception {
val request = new MockHttpServletRequest();
request.setRemoteAddr("1.2.3.4");
request.setLocalAddr("1.2.3.4");
ClientInfoHolder.setClientInfo(new ClientInfo(request));
val token = passwordManagementService.createToken(PasswordManagementQuery.builder().username("casuser").build());
val context = new MockRequestContext();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
assertEquals(CasWebflowConstants.TRANSITION_ID_ERROR, initPasswordResetAction.execute(context).getId());
context.getFlowScope().put("token", token);
assertEquals(CasWebflowConstants.TRANSITION_ID_SUCCESS, initPasswordResetAction.execute(context).getId());
val c = WebUtils.getCredential(context, UsernamePasswordCredential.class);
assertNotNull(c);
assertEquals("casuser", c.getUsername());
}
use of org.apereo.inspektr.common.web.ClientInfo in project cas by apereo.
the class RememberMeAuthenticationMetaDataPopulatorTests method verifyRememberMeUserAgent.
@Test
public void verifyRememberMeUserAgent() {
val request = new MockHttpServletRequest();
request.setRemoteAddr("185.86.151.11");
request.setLocalAddr("185.88.151.11");
request.addHeader(HttpRequestUtils.USER_AGENT_HEADER, "Chrome");
ClientInfoHolder.setClientInfo(new ClientInfo(request));
val c = new RememberMeUsernamePasswordCredential();
c.setRememberMe(true);
val builder = newBuilder(c, new RememberMeAuthenticationProperties().setSupportedUserAgents("Chrome"));
val auth = builder.build();
assertEquals(true, auth.getAttributes().get(RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME).get(0));
}
use of org.apereo.inspektr.common.web.ClientInfo in project cas by apereo.
the class MultifactorAuthenticationSetTrustActionTests method beforeEach.
@BeforeEach
public void beforeEach() {
this.context = new MockRequestContext();
WebUtils.putServiceIntoFlowScope(context, RegisteredServiceTestUtils.getService());
val registeredService = RegisteredServiceTestUtils.getRegisteredService("sample-service", Collections.EMPTY_MAP);
WebUtils.putRegisteredService(context, registeredService);
request = new MockHttpServletRequest();
request.setRemoteAddr("123.456.789.000");
request.setLocalAddr("123.456.789.000");
request.addHeader(HttpRequestUtils.USER_AGENT_HEADER, "test");
ClientInfoHolder.setClientInfo(new ClientInfo(request));
val response = new MockHttpServletResponse();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
ExternalContextHolder.setExternalContext(context.getExternalContext());
val authn = RegisteredServiceTestUtils.getAuthentication("casuser-setdevice");
WebUtils.putAuthentication(authn, context);
ApplicationContextProvider.holdApplicationContext(applicationContext);
}
use of org.apereo.inspektr.common.web.ClientInfo in project cas by apereo.
the class ClientIpDeviceFingerprintComponentManagerTests method verifyClientIpFingerprintFound.
@Test
public void verifyClientIpFingerprintFound() {
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
request.setRemoteAddr("1.2.3.4");
val clientInfo = new ClientInfo(request);
ClientInfoHolder.setClientInfo(clientInfo);
val ex = new ClientIpDeviceFingerprintComponentManager();
assertTrue(ex.extractComponent("casuser", request, response).isPresent());
}
use of org.apereo.inspektr.common.web.ClientInfo in project cas by apereo.
the class DefaultDeviceFingerprintStrategyTests method verifyAction.
@Test
public void verifyAction() {
val context = new MockRequestContext();
val request = new MockHttpServletRequest();
request.setRemoteAddr("123.456.789.000");
request.setLocalAddr("123.456.789.000");
request.addHeader(HttpRequestUtils.USER_AGENT_HEADER, "test");
ClientInfoHolder.setClientInfo(new ClientInfo(request));
val response = new MockHttpServletResponse();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
val f1 = deviceFingerprintStrategy.determineFingerprintComponent("casuser", request, response);
request.setCookies(response.getCookies());
val f2 = deviceFingerprintStrategy.determineFingerprintComponent("casuser", request, response);
request.setCookies(response.getCookies());
assertEquals(f1, f2);
val f3 = deviceFingerprintStrategy.determineFingerprintComponent("casuser", request, response);
assertNotNull(response.getCookies());
assertEquals(response.getCookies().length, 1);
request.setCookies(response.getCookies());
val f4 = deviceFingerprintStrategy.determineFingerprintComponent("casuser", request, response);
assertEquals(f3, f4);
}
Aggregations