use of org.apereo.inspektr.common.web.ClientInfo in project cas by apereo.
the class ThrottledSubmissionHandlerEndpointTests method verifyOperation.
@Test
public void verifyOperation() {
assertTrue(throttledSubmissionHandlerEndpoint.getRecords().isEmpty());
val request = new MockHttpServletRequest();
request.setRemoteAddr("1.2.3.4");
request.setLocalAddr("4.5.6.7");
request.setRemoteUser("cas");
request.addHeader("User-Agent", "Firefox");
ClientInfoHolder.setClientInfo(new ClientInfo(request));
throttle.recordSubmissionFailure(request);
assertFalse(throttledSubmissionHandlerEndpoint.getRecords().isEmpty());
}
use of org.apereo.inspektr.common.web.ClientInfo in project cas by apereo.
the class WsFederationNavigationControllerTests method verifyOperation.
@Test
public void verifyOperation() {
val context = new MockRequestContext();
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
RequestContextHolder.setRequestContext(context);
ExternalContextHolder.setExternalContext(context.getExternalContext());
request.setRemoteAddr("185.86.151.11");
request.setLocalAddr("185.88.151.11");
request.addHeader(HttpRequestUtils.USER_AGENT_HEADER, "Mozilla/5.0 (Windows NT 10.0; WOW64)");
ClientInfoHolder.setClientInfo(new ClientInfo(request));
val config = wsFederationConfigurations.toList().get(0);
val registeredService = RegisteredServiceTestUtils.getRegisteredService("https://wsfedservice");
registeredService.setProperties(Map.of(RegisteredServiceProperty.RegisteredServiceProperties.WSFED_RELYING_PARTY_ID.getPropertyName(), new DefaultRegisteredServiceProperty(config.getRelyingPartyIdentifier())));
val service = RegisteredServiceTestUtils.getService(registeredService.getServiceId());
servicesManager.save(registeredService);
request.addParameter(CasProtocolConstants.PARAMETER_SERVICE, service.getId());
val id = config.getId();
request.addParameter(WsFederationNavigationController.PARAMETER_NAME, id);
val view = wsFederationNavigationController.redirectToProvider(request, response);
assertTrue(view instanceof RedirectView);
}
use of org.apereo.inspektr.common.web.ClientInfo in project cas by apereo.
the class AccepttoMultifactorDetermineUserAccountStatusActionTests method prepareRequestContext.
private static MockRequestContext prepareRequestContext() {
val context = new MockRequestContext();
val request = new MockHttpServletRequest();
request.setRemoteAddr("185.86.151.11");
request.setLocalAddr("185.88.151.11");
request.setCookies(new Cookie("jwt", UUID.randomUUID().toString()));
ClientInfoHolder.setClientInfo(new ClientInfo(request));
val response = new MockHttpServletResponse();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
AccepttoWebflowUtils.setEGuardianUserId(context, "eguardian-userid");
WebUtils.putCredential(context, new AccepttoEmailCredential("cas@example.org"));
return context;
}
use of org.apereo.inspektr.common.web.ClientInfo in project cas by apereo.
the class AccepttoMultifactorValidateChannelActionTests method verifyOperation.
@Test
public void verifyOperation() throws Exception {
val httpRequest = new MockHttpServletRequest();
httpRequest.setRemoteAddr("185.86.151.11");
httpRequest.setLocalAddr("185.88.151.11");
ClientInfoHolder.setClientInfo(new ClientInfo(httpRequest));
val data = MAPPER.writeValueAsString(CollectionUtils.wrap("channel", "test-channel", "status", "approved", "device_id", "deviceid-123456"));
try (val webServer = new MockWebServer(5001, new ByteArrayResource(data.getBytes(StandardCharsets.UTF_8), "Output"), HttpStatus.OK)) {
webServer.start();
val action = new AccepttoMultifactorValidateChannelAction(mfaAccepttoDistributedSessionStore, authenticationSystemSupport);
val context = new MockRequestContext();
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
val webContext = new JEEContext(request, response);
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
val authn = CoreAuthenticationTestUtils.getAuthentication("casuser");
WebUtils.putAuthentication(authn, context);
AccepttoWebflowUtils.storeChannelInSessionStore("test-channel", webContext, mfaAccepttoDistributedSessionStore);
AccepttoWebflowUtils.storeAuthenticationInSessionStore(authn, webContext, mfaAccepttoDistributedSessionStore);
RequestContextHolder.setRequestContext(context);
val result = action.doExecute(context);
assertEquals(CasWebflowConstants.TRANSITION_ID_FINALIZE, result.getId());
}
}
use of org.apereo.inspektr.common.web.ClientInfo in project cas by apereo.
the class AccepttoQRCodeValidateWebSocketChannelActionTests method verifyMissingChannel.
@Test
public void verifyMissingChannel() throws Exception {
val httpRequest = new MockHttpServletRequest();
httpRequest.setRemoteAddr("185.86.151.11");
httpRequest.setLocalAddr("185.88.151.11");
ClientInfoHolder.setClientInfo(new ClientInfo(httpRequest));
val data = MAPPER.writeValueAsString(CollectionUtils.wrap("success", "true", "user_email", "cas@example.org"));
try (val webServer = new MockWebServer(5012, new ByteArrayResource(data.getBytes(StandardCharsets.UTF_8), "Output"), HttpStatus.OK)) {
webServer.start();
val action = new AccepttoQRCodeValidateWebSocketChannelAction(casProperties, mfaAccepttoDistributedSessionStore);
val context = new MockRequestContext();
val response = new MockHttpServletResponse();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), httpRequest, response));
WebUtils.putAuthentication(CoreAuthenticationTestUtils.getAuthentication("casuser"), context);
RequestContextHolder.setRequestContext(context);
AccepttoWebflowUtils.setChannel(context, "test-channel");
val result = action.doExecute(context);
assertEquals(CasWebflowConstants.TRANSITION_ID_AUTHENTICATION_FAILURE, result.getId());
}
}
Aggregations