use of org.apereo.inspektr.common.web.ClientInfo in project cas by apereo.
the class LdapAcceptableUsagePolicyRepositoryTests method bootstrap.
@BeforeAll
public static void bootstrap() throws Exception {
ClientInfoHolder.setClientInfo(new ClientInfo(new MockHttpServletRequest()));
@Cleanup val localhost = new LDAPConnection("localhost", LDAP_PORT, "cn=Directory Manager", "password");
val ldif = IOUtils.toString(new ClassPathResource("ldif/ldap-aup.ldif").getInputStream(), StandardCharsets.UTF_8).replace("$user", USER);
LdapIntegrationTestsOperations.populateEntries(localhost, new ByteArrayInputStream(ldif.getBytes(StandardCharsets.UTF_8)), "ou=people,dc=example,dc=org");
}
use of org.apereo.inspektr.common.web.ClientInfo in project cas by apereo.
the class BaseDuoSecurityTests method getMockRequestContext.
public static RequestContext getMockRequestContext(final ConfigurableApplicationContext applicationContext) {
val context = new MockRequestContext();
val request = new MockHttpServletRequest();
request.setRemoteAddr("185.86.151.11");
request.setLocalAddr("195.88.151.11");
request.addHeader(HttpRequestUtils.USER_AGENT_HEADER, "MSIE");
ClientInfoHolder.setClientInfo(new ClientInfo(request));
val response = new MockHttpServletResponse();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
val provider = getDuoSecurityMultifactorAuthenticationProvider();
TestMultifactorAuthenticationProvider.registerProviderIntoApplicationContext(applicationContext, provider);
val targetResolver = new DefaultTargetStateResolver(provider.getId());
val transition = new Transition(new DefaultTransitionCriteria(new LiteralExpression(provider.getId())), targetResolver);
context.getRootFlow().getGlobalTransitionSet().add(transition);
WebUtils.putServiceIntoFlowScope(context, CoreAuthenticationTestUtils.getWebApplicationService());
val authentication = CoreAuthenticationTestUtils.getAuthentication();
WebUtils.putAuthentication(authentication, context);
val builder = mock(AuthenticationResultBuilder.class);
when(builder.getInitialAuthentication()).thenReturn(Optional.of(authentication));
when(builder.collect(any(Authentication.class))).thenReturn(builder);
WebUtils.putAuthenticationResultBuilder(builder, context);
return context;
}
use of org.apereo.inspektr.common.web.ClientInfo in project cas by apereo.
the class OpenLdapPasswordManagementServiceTests method bootstrap.
@BeforeAll
public static void bootstrap() throws Exception {
ClientInfoHolder.setClientInfo(new ClientInfo(new MockHttpServletRequest()));
val localhost = new LDAPConnection("localhost", LDAP_PORT, "cn=admin,dc=example,dc=org", "P@ssw0rd");
LdapIntegrationTestsOperations.populateEntries(localhost, new ClassPathResource("ldif/openldap-pm.ldif").getInputStream(), "ou=people,dc=example,dc=org", new BindConnectionInitializer("cn=admin,dc=example,dc=org", new Credential("P@ssw0rd")));
}
use of org.apereo.inspektr.common.web.ClientInfo in project cas by apereo.
the class BaseThrottledSubmissionHandlerInterceptorAdapterTests method initialize.
@BeforeEach
public void initialize() {
val request = new MockHttpServletRequest();
request.setRemoteAddr(IP_ADDRESS);
request.setLocalAddr(IP_ADDRESS);
ClientInfoHolder.setClientInfo(new ClientInfo(request));
}
use of org.apereo.inspektr.common.web.ClientInfo in project cas by apereo.
the class RestfulSmsSenderTests method initialize.
@BeforeEach
public void initialize() {
val request = new MockHttpServletRequest();
request.setRemoteAddr("185.86.151.11");
request.setLocalAddr("185.88.151.11");
ClientInfoHolder.setClientInfo(new ClientInfo(request));
webServer = new MockWebServer(8132, new ByteArrayResource(StringUtils.EMPTY.getBytes(StandardCharsets.UTF_8), "REST Output"), MediaType.APPLICATION_JSON_VALUE);
this.webServer.start();
}
Aggregations