Search in sources :

Example 1 with RememberMeAuthenticationProperties

use of org.apereo.cas.configuration.model.core.ticket.RememberMeAuthenticationProperties in project cas by apereo.

the class RememberMeAuthenticationMetaDataPopulatorTests method verifyWithoutRememberMeCredentials.

@Test
public void verifyWithoutRememberMeCredentials() {
    val builder = newBuilder(CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword(), new RememberMeAuthenticationProperties());
    val auth = builder.build();
    assertNull(auth.getAttributes().get(RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME));
}
Also used : lombok.val(lombok.val) RememberMeAuthenticationProperties(org.apereo.cas.configuration.model.core.ticket.RememberMeAuthenticationProperties) Test(org.junit.jupiter.api.Test)

Example 2 with RememberMeAuthenticationProperties

use of org.apereo.cas.configuration.model.core.ticket.RememberMeAuthenticationProperties in project cas by apereo.

the class RememberMeAuthenticationMetaDataPopulatorTests method verifyWithTrueRememberMeCredentials.

@Test
public void verifyWithTrueRememberMeCredentials() {
    val c = new RememberMeUsernamePasswordCredential();
    c.setRememberMe(true);
    val builder = newBuilder(c, new RememberMeAuthenticationProperties());
    val auth = builder.build();
    assertEquals(true, auth.getAttributes().get(RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME).get(0));
}
Also used : lombok.val(lombok.val) RememberMeAuthenticationProperties(org.apereo.cas.configuration.model.core.ticket.RememberMeAuthenticationProperties) RememberMeUsernamePasswordCredential(org.apereo.cas.authentication.credential.RememberMeUsernamePasswordCredential) Test(org.junit.jupiter.api.Test)

Example 3 with RememberMeAuthenticationProperties

use of org.apereo.cas.configuration.model.core.ticket.RememberMeAuthenticationProperties in project cas by apereo.

the class RememberMeAuthenticationMetaDataPopulatorTests method verifyWithFalseRememberMeCredentials.

@Test
public void verifyWithFalseRememberMeCredentials() {
    val c = new RememberMeUsernamePasswordCredential();
    c.setRememberMe(false);
    val builder = newBuilder(c, new RememberMeAuthenticationProperties());
    val auth = builder.build();
    assertNull(auth.getAttributes().get(RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME));
}
Also used : lombok.val(lombok.val) RememberMeAuthenticationProperties(org.apereo.cas.configuration.model.core.ticket.RememberMeAuthenticationProperties) RememberMeUsernamePasswordCredential(org.apereo.cas.authentication.credential.RememberMeUsernamePasswordCredential) Test(org.junit.jupiter.api.Test)

Example 4 with RememberMeAuthenticationProperties

use of org.apereo.cas.configuration.model.core.ticket.RememberMeAuthenticationProperties in project cas by apereo.

the class RememberMeAuthenticationMetaDataPopulatorTests method verifyRememberMeIp.

@Test
public void verifyRememberMeIp() {
    val request = new MockHttpServletRequest();
    request.setRemoteAddr("185.86.151.11");
    request.setLocalAddr("185.88.151.11");
    ClientInfoHolder.setClientInfo(new ClientInfo(request));
    val c = new RememberMeUsernamePasswordCredential();
    c.setRememberMe(true);
    val builder = newBuilder(c, new RememberMeAuthenticationProperties().setSupportedIpAddresses("192.+"));
    val auth = builder.build();
    assertFalse(auth.getAttributes().containsKey(RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME));
}
Also used : lombok.val(lombok.val) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) ClientInfo(org.apereo.inspektr.common.web.ClientInfo) RememberMeAuthenticationProperties(org.apereo.cas.configuration.model.core.ticket.RememberMeAuthenticationProperties) RememberMeUsernamePasswordCredential(org.apereo.cas.authentication.credential.RememberMeUsernamePasswordCredential) Test(org.junit.jupiter.api.Test)

Example 5 with RememberMeAuthenticationProperties

use of org.apereo.cas.configuration.model.core.ticket.RememberMeAuthenticationProperties in project cas by apereo.

the class RememberMeAuthenticationMetaDataPopulatorTests method verifyRememberMeUserAgentAndIp.

@Test
public void verifyRememberMeUserAgentAndIp() {
    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").setSupportedIpAddresses("123.+"));
    val auth = builder.build();
    assertFalse(auth.getAttributes().containsKey(RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME));
}
Also used : lombok.val(lombok.val) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) ClientInfo(org.apereo.inspektr.common.web.ClientInfo) RememberMeAuthenticationProperties(org.apereo.cas.configuration.model.core.ticket.RememberMeAuthenticationProperties) RememberMeUsernamePasswordCredential(org.apereo.cas.authentication.credential.RememberMeUsernamePasswordCredential) Test(org.junit.jupiter.api.Test)

Aggregations

lombok.val (lombok.val)7 RememberMeAuthenticationProperties (org.apereo.cas.configuration.model.core.ticket.RememberMeAuthenticationProperties)7 Test (org.junit.jupiter.api.Test)7 RememberMeUsernamePasswordCredential (org.apereo.cas.authentication.credential.RememberMeUsernamePasswordCredential)5 ClientInfo (org.apereo.inspektr.common.web.ClientInfo)3 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)3 List (java.util.List)1 Set (java.util.Set)1 SimpleTestUsernamePasswordAuthenticationHandler (org.apereo.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler)1 RememberMeAuthenticationMetaDataPopulator (org.apereo.cas.authentication.metadata.RememberMeAuthenticationMetaDataPopulator)1 AllCredentialsValidatedAuthenticationPolicy (org.apereo.cas.authentication.policy.AllCredentialsValidatedAuthenticationPolicy)1 PrincipalFactoryUtils (org.apereo.cas.authentication.principal.PrincipalFactoryUtils)1 PersonDirectoryPrincipalResolver (org.apereo.cas.authentication.principal.resolvers.PersonDirectoryPrincipalResolver)1 PrincipalResolutionContext (org.apereo.cas.authentication.principal.resolvers.PrincipalResolutionContext)1 PrincipalAttributesCoreProperties (org.apereo.cas.configuration.model.core.authentication.PrincipalAttributesCoreProperties)1 CollectionUtils (org.apereo.cas.util.CollectionUtils)1 IPersonAttributeDao (org.apereo.services.persondir.IPersonAttributeDao)1 Assertions (org.junit.jupiter.api.Assertions)1 Tag (org.junit.jupiter.api.Tag)1 Mockito (org.mockito.Mockito)1