use of org.apereo.cas.authentication.support.password.PasswordPolicyContext in project cas by apereo.
the class DefaultLdapAccountStateHandlerTests method verifyNoAttrs.
@Test
public void verifyNoAttrs() {
val handler = new DefaultLdapAccountStateHandler();
val response = mock(AuthenticationResponse.class);
handler.setAttributesToErrorMap(Map.of("attr1", AccountLockedException.class));
val entry = new LdapEntry();
when(response.getLdapEntry()).thenReturn(entry);
when(response.isSuccess()).thenReturn(Boolean.TRUE);
assertDoesNotThrow(new Executable() {
@Override
public void execute() throws Throwable {
handler.handle(response, new PasswordPolicyContext());
}
});
}
use of org.apereo.cas.authentication.support.password.PasswordPolicyContext in project cas by apereo.
the class OptionalWarningLdapAccountStateHandlerTests method verifyWarningOnMatch.
@Test
public void verifyWarningOnMatch() {
val h = new OptionalWarningLdapAccountStateHandler();
h.setWarnAttributeName("attribute");
h.setWarningAttributeValue("value");
h.setDisplayWarningOnMatch(true);
val response = mock(AuthenticationResponse.class);
val entry = mock(LdapEntry.class);
when(response.getLdapEntry()).thenReturn(entry);
when(entry.getAttribute(anyString())).thenReturn(new LdapAttribute("attribute", "value"));
val messages = new ArrayList<MessageDescriptor>();
val config = new PasswordPolicyContext();
config.setPasswordWarningNumberOfDays(5);
h.handleWarning(new AccountState.DefaultWarning(ZonedDateTime.now(ZoneId.systemDefault()), 1), response, config, messages);
assertEquals(2, messages.size());
}
use of org.apereo.cas.authentication.support.password.PasswordPolicyContext in project cas by apereo.
the class OptionalWarningLdapAccountStateHandlerTests method verifyAlwaysWarningOnMatch.
@Test
public void verifyAlwaysWarningOnMatch() {
val h = new OptionalWarningLdapAccountStateHandler();
h.setWarnAttributeName("attribute");
h.setWarningAttributeValue("value");
h.setDisplayWarningOnMatch(true);
val response = mock(AuthenticationResponse.class);
val entry = mock(LdapEntry.class);
when(response.getLdapEntry()).thenReturn(entry);
when(entry.getAttribute(anyString())).thenReturn(new LdapAttribute("attribute", "value"));
val messages = new ArrayList<MessageDescriptor>();
val config = new PasswordPolicyContext();
config.setAlwaysDisplayPasswordExpirationWarning(true);
h.handleWarning(new AccountState.DefaultWarning(ZonedDateTime.now(ZoneId.systemDefault()), 1), response, config, messages);
assertEquals(2, messages.size());
}
use of org.apereo.cas.authentication.support.password.PasswordPolicyContext in project cas by apereo.
the class OktaAuthenticationStateHandlerAdapterTests method verifyLockout.
@Test
public void verifyLockout() {
val adapter = new OktaAuthenticationStateHandlerAdapter(new DefaultPasswordPolicyHandlingStrategy<>(), new PasswordPolicyContext());
val response = mock(AuthenticationResponse.class);
when(response.getStatusString()).thenReturn("error");
adapter.handleLockedOut(response);
assertThrows(AccountLockedException.class, adapter::throwExceptionIfNecessary);
}
use of org.apereo.cas.authentication.support.password.PasswordPolicyContext in project cas by apereo.
the class OktaAuthenticationStateHandlerAdapterTests method verifyUnknown.
@Test
public void verifyUnknown() {
val adapter = new OktaAuthenticationStateHandlerAdapter(new DefaultPasswordPolicyHandlingStrategy<>(), new PasswordPolicyContext());
val response = mock(AuthenticationResponse.class);
when(response.getStatusString()).thenReturn("error");
adapter.handleUnknown(response);
assertThrows(AccountNotFoundException.class, adapter::throwExceptionIfNecessary);
}
Aggregations