use of org.apereo.inspektr.common.web.ClientInfo in project cas by apereo.
the class OidcAuthenticationContextWebflowEventResolverTests method initialize.
@BeforeEach
@Override
public void initialize() throws Exception {
super.initialize();
this.context = new MockRequestContext();
val request = new MockHttpServletRequest();
request.setRemoteAddr("385.86.151.11");
request.setLocalAddr("295.88.151.11");
request.addHeader(HttpRequestUtils.USER_AGENT_HEADER, "MSIE");
request.addParameter(OAuth20Constants.ACR_VALUES, TestMultifactorAuthenticationProvider.ID);
ClientInfoHolder.setClientInfo(new ClientInfo(request));
val response = new MockHttpServletResponse();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
val targetResolver = new DefaultTargetStateResolver(TestMultifactorAuthenticationProvider.ID);
val transition = new Transition(new DefaultTransitionCriteria(new LiteralExpression(TestMultifactorAuthenticationProvider.ID)), targetResolver);
context.getRootFlow().getGlobalTransitionSet().add(transition);
WebUtils.putServiceIntoFlowScope(context, CoreAuthenticationTestUtils.getWebApplicationService());
TestMultifactorAuthenticationProvider.registerProviderIntoApplicationContext(applicationContext);
WebUtils.putAuthentication(CoreAuthenticationTestUtils.getAuthentication(), context);
}
use of org.apereo.inspektr.common.web.ClientInfo in project cas by apereo.
the class PrincipalFromRequestHeaderNonInteractiveCredentialsActionTests method verifyAdaptiveError.
@Test
public void verifyAdaptiveError() throws Exception {
val context = new MockRequestContext();
val messageContext = (DefaultMessageContext) context.getMessageContext();
messageContext.setMessageSource(mock(MessageSource.class));
val request = new MockHttpServletRequest();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
request.setRemoteUser("xyz");
request.setRemoteAddr("1.2.3.4");
request.setLocalAddr("1.2.3.4");
request.addHeader(HttpRequestUtils.USER_AGENT_HEADER, "FIREFOX");
request.addParameter("geolocation", "1000,1000,1000,1000");
ClientInfoHolder.setClientInfo(new ClientInfo(request));
request.addParameter(casProperties.getAuthn().getMfa().getTriggers().getHttp().getRequestParameter(), "mfa-whatever");
WebUtils.putServiceIntoFlowScope(context, RegisteredServiceTestUtils.getService());
assertEquals(CasWebflowConstants.TRANSITION_ID_AUTHENTICATION_FAILURE, this.action.execute(context).getId());
}
use of org.apereo.inspektr.common.web.ClientInfo in project cas by apereo.
the class BaseEndpointLdapAuthenticationProviderTests method bootstrap.
@BeforeAll
@SneakyThrows
public static void bootstrap() {
ClientInfoHolder.setClientInfo(new ClientInfo(new MockHttpServletRequest()));
val localhost = new LDAPConnection("localhost", LDAP_PORT, "cn=Directory Manager", "password");
localhost.connect("localhost", LDAP_PORT);
localhost.bind("cn=Directory Manager", "password");
LdapIntegrationTestsOperations.populateEntries(localhost, new ClassPathResource("ldif/ldap-authz.ldif").getInputStream(), "ou=people,dc=example,dc=org");
}
use of org.apereo.inspektr.common.web.ClientInfo in project cas by apereo.
the class DefaultAccountRegistrationServiceTests method setup.
@BeforeEach
public void setup() {
this.accountRegistrationService = new DefaultAccountRegistrationService(mock(AccountRegistrationPropertyLoader.class), casProperties, CipherExecutor.noOpOfSerializableToString(), AccountRegistrationUsernameBuilder.asDefault(), mock(AccountRegistrationProvisioner.class));
val request = new MockHttpServletRequest();
request.setRemoteAddr("1.2.3.4");
request.setLocalAddr("1.2.3.4");
ClientInfoHolder.setClientInfo(new ClientInfo(request));
}
use of org.apereo.inspektr.common.web.ClientInfo in project cas by apereo.
the class ValidateAccountRegistrationTokenActionTests method verifyPassRegistrationRequest.
@Test
public void verifyPassRegistrationRequest() throws Exception {
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("127.0.0.1");
request.setLocalAddr("127.0.0.1");
ClientInfoHolder.setClientInfo(new ClientInfo(request));
request.addParameter("username", "casuser");
request.addParameter("email", "cas@example.org");
request.addParameter("phone", "3477465432");
val results = submitAccountRegistrationAction.execute(context);
val token = new URIBuilder(results.getAttributes().get("result", String.class)).getQueryParams().get(0).getValue();
request.addParameter(AccountRegistrationUtils.REQUEST_PARAMETER_ACCOUNT_REGISTRATION_ACTIVATION_TOKEN, token);
assertEquals(CasWebflowConstants.TRANSITION_ID_SUCCESS, validateAction.execute(context).getId());
}
Aggregations