use of org.apereo.cas.pm.PasswordChangeRequest in project cas by apereo.
the class PasswordChangeActionTests method verifyChange.
@Test
public void verifyChange() 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());
WebUtils.putCredential(context, RegisteredServiceTestUtils.getCredentialsWithDifferentUsernameAndPassword("casuser", "Th!$isT3$t"));
val changeReq = new PasswordChangeRequest();
changeReq.setUsername("casuser");
changeReq.setPassword("P@ssword");
changeReq.setConfirmedPassword("P@ssword");
context.getFlowScope().put(PasswordManagementWebflowConfigurer.FLOW_VAR_ID_PASSWORD, changeReq);
assertEquals(CasWebflowConstants.TRANSITION_ID_PASSWORD_UPDATE_SUCCESS, passwordChangeAction.execute(context).getId());
}
use of org.apereo.cas.pm.PasswordChangeRequest in project cas by apereo.
the class PasswordChangeActionTests method verifyChangeFails.
@Test
public void verifyChangeFails() 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());
WebUtils.putCredential(context, RegisteredServiceTestUtils.getCredentialsWithDifferentUsernameAndPassword("bad-credential", "P@ssword"));
val changeReq = new PasswordChangeRequest();
changeReq.setUsername("bad-credential");
changeReq.setPassword("P@ssword");
changeReq.setConfirmedPassword("P@ssword");
context.getFlowScope().put(PasswordManagementWebflowConfigurer.FLOW_VAR_ID_PASSWORD, changeReq);
assertEquals(CasWebflowConstants.TRANSITION_ID_ERROR, passwordChangeAction.execute(context).getId());
}
use of org.apereo.cas.pm.PasswordChangeRequest in project cas by apereo.
the class NoOpPasswordManagementServiceTests method verifyChange.
@Test
public void verifyChange() {
val properties = new PasswordManagementProperties();
val service = new NoOpPasswordManagementService(CipherExecutor.noOpOfSerializableToString(), "CAS", properties);
assertFalse(service.changeInternal(RegisteredServiceTestUtils.getCredentialsWithSameUsernameAndPassword("casuser"), new PasswordChangeRequest()));
}
use of org.apereo.cas.pm.PasswordChangeRequest in project cas by apereo.
the class PasswordChangeActionTests method verifyPasswordRejected.
@Test
public void verifyPasswordRejected() 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());
WebUtils.putCredential(context, RegisteredServiceTestUtils.getCredentialsWithDifferentUsernameAndPassword("error-credential", "P@ssword"));
val changeReq = new PasswordChangeRequest();
changeReq.setUsername("error-credential");
changeReq.setPassword("P@ssword");
changeReq.setConfirmedPassword("P@ssword");
context.getFlowScope().put(PasswordManagementWebflowConfigurer.FLOW_VAR_ID_PASSWORD, changeReq);
assertEquals(CasWebflowConstants.TRANSITION_ID_ERROR, passwordChangeAction.execute(context).getId());
}
use of org.apereo.cas.pm.PasswordChangeRequest in project cas by apereo.
the class PasswordChangeActionTests method verifyFailNoCreds.
@Test
public void verifyFailNoCreds() 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());
val changeReq = new PasswordChangeRequest();
changeReq.setUsername("casuser");
changeReq.setPassword("123456");
context.getFlowScope().put(PasswordManagementWebflowConfigurer.FLOW_VAR_ID_PASSWORD, changeReq);
assertEquals(CasWebflowConstants.TRANSITION_ID_ERROR, passwordChangeAction.execute(context).getId());
}
Aggregations