Search in sources :

Example 1 with PasswordChangeRequest

use of org.apereo.cas.pm.PasswordChangeRequest in project cas by apereo.

the class JdbcPasswordManagementServiceTests method verifyUserPasswordChange.

@Test
public void verifyUserPasswordChange() {
    val c = new UsernamePasswordCredential("casuser", "password");
    val bean = new PasswordChangeRequest();
    bean.setConfirmedPassword("newPassword1");
    bean.setUsername(c.getUsername());
    bean.setPassword("newPassword1");
    assertTrue(passwordChangeService.change(c, bean));
    assertFalse(passwordHistoryService.fetch(c.getUsername()).isEmpty());
    assertFalse(passwordChangeService.change(c, bean));
}
Also used : lombok.val(lombok.val) PasswordChangeRequest(org.apereo.cas.pm.PasswordChangeRequest) UsernamePasswordCredential(org.apereo.cas.authentication.credential.UsernamePasswordCredential) Test(org.junit.jupiter.api.Test)

Example 2 with PasswordChangeRequest

use of org.apereo.cas.pm.PasswordChangeRequest in project cas by apereo.

the class InMemoryPasswordHistoryServiceTests method verifyValidity.

@Test
public void verifyValidity() {
    passwordHistoryService.removeAll();
    assertTrue(passwordHistoryService.fetchAll().isEmpty());
    val request = new PasswordChangeRequest("casuser", "password", "password");
    assertFalse(passwordHistoryService.exists(request));
    assertTrue(passwordHistoryService.store(request));
    assertTrue(passwordHistoryService.exists(request));
    assertFalse(passwordHistoryService.fetchAll().isEmpty());
    assertFalse(passwordHistoryService.fetch("casuser").isEmpty());
    passwordHistoryService.remove("casuser");
    assertTrue(passwordHistoryService.fetch("casuser").isEmpty());
}
Also used : lombok.val(lombok.val) PasswordChangeRequest(org.apereo.cas.pm.PasswordChangeRequest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with PasswordChangeRequest

use of org.apereo.cas.pm.PasswordChangeRequest in project cas by apereo.

the class JsonResourcePasswordManagementServiceTests method verifyPasswordValidationService.

@Test
public void verifyPasswordValidationService() {
    val c = new UsernamePasswordCredential("casuser", "password");
    val bean = new PasswordChangeRequest();
    bean.setUsername(c.getUsername());
    bean.setConfirmedPassword("Test1@1234");
    bean.setPassword("Test1@1234");
    val isValid = passwordValidationService.isValid(c, bean);
    assertTrue(isValid);
}
Also used : lombok.val(lombok.val) PasswordChangeRequest(org.apereo.cas.pm.PasswordChangeRequest) UsernamePasswordCredential(org.apereo.cas.authentication.credential.UsernamePasswordCredential) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with PasswordChangeRequest

use of org.apereo.cas.pm.PasswordChangeRequest in project cas by apereo.

the class JsonResourcePasswordManagementServiceTests method verifyUserPasswordChangeFail.

@Test
public void verifyUserPasswordChangeFail() {
    val c = new UsernamePasswordCredential("casuser", "password");
    val bean = new PasswordChangeRequest();
    bean.setConfirmedPassword("newPassword");
    var res = passwordChangeService.change(c, bean);
    assertFalse(res);
    bean.setConfirmedPassword("newPassword");
    bean.setPassword("unknown");
    res = passwordChangeService.change(c, bean);
    assertFalse(res);
    bean.setPassword(bean.getConfirmedPassword());
    c.setUsername(UUID.randomUUID().toString());
    res = passwordChangeService.change(c, bean);
    assertFalse(res);
}
Also used : lombok.val(lombok.val) PasswordChangeRequest(org.apereo.cas.pm.PasswordChangeRequest) UsernamePasswordCredential(org.apereo.cas.authentication.credential.UsernamePasswordCredential) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 5 with PasswordChangeRequest

use of org.apereo.cas.pm.PasswordChangeRequest in project cas by apereo.

the class JsonResourcePasswordManagementServiceTests method verifyUserPasswordChange.

@Test
public void verifyUserPasswordChange() {
    val c = new UsernamePasswordCredential("casuser", "password");
    val bean = new PasswordChangeRequest();
    bean.setConfirmedPassword("newPassword");
    bean.setPassword("newPassword");
    val res = passwordChangeService.change(c, bean);
    assertTrue(res);
}
Also used : lombok.val(lombok.val) PasswordChangeRequest(org.apereo.cas.pm.PasswordChangeRequest) UsernamePasswordCredential(org.apereo.cas.authentication.credential.UsernamePasswordCredential) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

lombok.val (lombok.val)13 PasswordChangeRequest (org.apereo.cas.pm.PasswordChangeRequest)13 Test (org.junit.jupiter.api.Test)13 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)5 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)5 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)5 MockServletContext (org.springframework.mock.web.MockServletContext)5 ServletExternalContext (org.springframework.webflow.context.servlet.ServletExternalContext)5 MockRequestContext (org.springframework.webflow.test.MockRequestContext)5 UsernamePasswordCredential (org.apereo.cas.authentication.credential.UsernamePasswordCredential)4 PasswordManagementProperties (org.apereo.cas.configuration.model.support.pm.PasswordManagementProperties)1 Executable (org.junit.jupiter.api.function.Executable)1