use of org.apereo.cas.authentication.support.password.PasswordPolicyContext in project cas by apereo.
the class OktaAuthenticationStateHandlerAdapterTests method handleSuccessWithoutToken.
@Test
public void handleSuccessWithoutToken() {
val adapter = new OktaAuthenticationStateHandlerAdapter(new DefaultPasswordPolicyHandlingStrategy<>(), new PasswordPolicyContext());
val response = mock(AuthenticationResponse.class);
when(response.getSessionToken()).thenReturn(null);
adapter.handleSuccess(response);
assertNotNull(adapter.getFailureException());
assertNotNull(adapter.getPasswordPolicyHandlingStrategy());
assertNotNull(adapter.getPasswordPolicyConfiguration());
assertThrows(FailedLoginException.class, adapter::throwExceptionIfNecessary);
}
use of org.apereo.cas.authentication.support.password.PasswordPolicyContext in project cas by apereo.
the class OktaAuthenticationStateHandlerAdapterTests method handlePasswordReset.
@Test
public void handlePasswordReset() {
val adapter = new OktaAuthenticationStateHandlerAdapter(new DefaultPasswordPolicyHandlingStrategy<>(), new PasswordPolicyContext());
val response = mock(AuthenticationResponse.class);
when(response.getStatusString()).thenReturn("error");
adapter.handlePasswordReset(response);
assertThrows(AccountPasswordMustChangeException.class, adapter::throwExceptionIfNecessary);
}
use of org.apereo.cas.authentication.support.password.PasswordPolicyContext in project cas by apereo.
the class OptionalWarningLdapAccountStateHandlerTests method verifyWarningNoAttr.
@Test
public void verifyWarningNoAttr() {
val h = new OptionalWarningLdapAccountStateHandler();
h.setDisplayWarningOnMatch(true);
val response = mock(AuthenticationResponse.class);
val config = new PasswordPolicyContext();
config.setPasswordWarningNumberOfDays(5);
val list = new ArrayList<MessageDescriptor>();
h.handleWarning(new AccountState.DefaultWarning(ZonedDateTime.now(ZoneId.systemDefault()), 1), response, config, list);
assertTrue(list.isEmpty());
h.setWarnAttributeName("attribute");
h.handleWarning(new AccountState.DefaultWarning(ZonedDateTime.now(ZoneId.systemDefault()), 1), response, config, list);
assertTrue(list.isEmpty());
}
Aggregations