Search in sources :

Example 66 with IdmPasswordDto

use of eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto in project CzechIdMng by bcvsolutions.

the class DefaultIdmPasswordServiceIntegrationTest method testTwoPoliciesSecondValidTillNull.

@Test
public void testTwoPoliciesSecondValidTillNull() {
    IdmPasswordPolicyDto policy1 = getTestPolicy(false, IdmPasswordPolicyType.VALIDATE, null);
    IdmPasswordPolicyDto policy2 = getTestPolicy(true, IdmPasswordPolicyType.VALIDATE, 5);
    IdmIdentityDto identity = getHelper().createIdentity();
    // 
    IdmPasswordDto password = passwordService.findOneByIdentity(identity.getId());
    Assert.assertNull(password.getValidFrom());
    assertEquals(identity.getId(), password.getIdentity());
    assertEquals(LocalDate.now().plusDays(policy2.getMaxPasswordAge()), password.getValidTill());
    // 
    policy1.setDefaultPolicy(true);
    policy1 = policyService.save(policy1);
    PasswordChangeDto passwordChangeDto = new PasswordChangeDto();
    passwordChangeDto.setAll(true);
    passwordChangeDto.setIdm(true);
    passwordChangeDto.setOldPassword(identity.getPassword());
    passwordChangeDto.setNewPassword(new GuardedString("testPassword"));
    // 
    try {
        getHelper().login(identity);
        identityService.passwordChange(identity, passwordChangeDto);
        password = passwordService.findOneByIdentity(identity.getId());
        Assert.assertNotNull(password.getValidFrom());
        Assert.assertNull(password.getValidTill());
    } finally {
        logout();
    }
}
Also used : IdmPasswordPolicyDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordPolicyDto) PasswordChangeDto(eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto) IdmPasswordDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 67 with IdmPasswordDto

use of eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto in project CzechIdMng by bcvsolutions.

the class DefaultIdmPasswordServiceIntegrationTest method testCreatePasswordValidationPolicy.

@Test
public void testCreatePasswordValidationPolicy() {
    getTestPolicy(false, IdmPasswordPolicyType.VALIDATE, 365);
    IdmIdentityDto identity = getHelper().createIdentity();
    // 
    IdmPasswordDto password = passwordService.findOneByIdentity(identity.getId());
    Assert.assertNull(password.getValidFrom());
    Assert.assertEquals(identity.getId(), password.getIdentity());
    Assert.assertNull(password.getValidTill());
}
Also used : IdmPasswordDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 68 with IdmPasswordDto

use of eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto in project CzechIdMng by bcvsolutions.

the class DefaultIdmPasswordServiceIntegrationTest method testCreatePasswordNoPolicy.

@Test
public void testCreatePasswordNoPolicy() {
    IdmIdentityDto identity = getHelper().createIdentity();
    IdmPasswordDto password = passwordService.findOneByIdentity(identity.getId());
    Assert.assertNull(password.getValidFrom());
    assertEquals(identity.getId(), password.getIdentity());
    assertNull(password.getValidTill());
}
Also used : IdmPasswordDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 69 with IdmPasswordDto

use of eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto in project CzechIdMng by bcvsolutions.

the class DefaultIdmPasswordServiceIntegrationTest method checkCorrectBehaviorTrue.

@Test
public void checkCorrectBehaviorTrue() {
    String password = "password" + System.currentTimeMillis();
    GuardedString passwordForCheck = new GuardedString(password);
    IdmPasswordDto newPassword = new IdmPasswordDto();
    newPassword.setPassword(generateHash(password));
    assertTrue(passwordService.checkPassword(passwordForCheck, newPassword));
}
Also used : IdmPasswordDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 70 with IdmPasswordDto

use of eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto in project CzechIdMng by bcvsolutions.

the class DefaultIdmPasswordServiceIntegrationTest method checkCorrectBehaviorFalse.

@Test
public void checkCorrectBehaviorFalse() {
    String password = "password" + System.currentTimeMillis();
    GuardedString passwordForCheck = new GuardedString(password + "2");
    IdmPasswordDto newPassword = new IdmPasswordDto();
    newPassword.setPassword(generateHash(password));
    assertFalse(passwordService.checkPassword(passwordForCheck, newPassword));
}
Also used : IdmPasswordDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

IdmPasswordDto (eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto)88 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)71 Test (org.junit.Test)65 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)53 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)52 IdmPasswordPolicyDto (eu.bcvsolutions.idm.core.api.dto.IdmPasswordPolicyDto)28 PasswordChangeDto (eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto)20 LoginDto (eu.bcvsolutions.idm.core.security.api.dto.LoginDto)19 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)11 Transactional (org.springframework.transaction.annotation.Transactional)11 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)10 AbstractPasswordFilterIntegrationTest (eu.bcvsolutions.idm.acc.AbstractPasswordFilterIntegrationTest)9 IdmLongRunningTaskDto (eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto)9 IdmProcessedTaskItemDto (eu.bcvsolutions.idm.core.scheduler.api.dto.IdmProcessedTaskItemDto)9 IdmScheduledTaskDto (eu.bcvsolutions.idm.core.scheduler.api.dto.IdmScheduledTaskDto)9 ZonedDateTime (java.time.ZonedDateTime)9 UUID (java.util.UUID)9 IdmPasswordFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmPasswordFilter)8 IdmAuthenticationException (eu.bcvsolutions.idm.core.security.api.exception.IdmAuthenticationException)8 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)7