use of eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmPasswordServiceIntegrationTest method testFilterMustChange.
@Test
public void testFilterMustChange() {
IdmIdentityDto identity = getHelper().createIdentity(new GuardedString("test" + System.currentTimeMillis()));
IdmPasswordFilter filter = new IdmPasswordFilter();
filter.setIdentityId(identity.getId());
List<IdmPasswordDto> passwords = passwordService.find(filter, null).getContent();
assertEquals(1, passwords.size());
IdmPasswordDto passwordDto = passwords.get(0);
assertEquals(identity.getId(), passwordDto.getIdentity());
passwordDto.setMustChange(true);
passwordService.save(passwordDto);
filter = new IdmPasswordFilter();
filter.setMustChange(true);
passwords = passwordService.find(filter, null).getContent();
assertEquals(1, passwords.size());
IdmPasswordDto passwordDtoTwo = passwords.get(0);
assertEquals(identity.getId(), passwordDtoTwo.getIdentity());
assertEquals(passwordDto.getId(), passwordDtoTwo.getId());
assertEquals(passwordDto.getPassword(), passwordDtoTwo.getPassword());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmPasswordServiceIntegrationTest method testFilterValidTill.
@Test
public void testFilterValidTill() {
IdmIdentityDto identityOne = getHelper().createIdentity(new GuardedString("test" + System.currentTimeMillis()));
IdmIdentityDto identityTwo = getHelper().createIdentity(new GuardedString("test" + System.currentTimeMillis()));
IdmIdentityDto identityTree = getHelper().createIdentity(new GuardedString("test" + System.currentTimeMillis()));
IdmPasswordFilter filter = new IdmPasswordFilter();
filter.setIdentityId(identityOne.getId());
IdmPasswordDto passwordOne = passwordService.find(filter, null).getContent().get(0);
filter.setIdentityId(identityTwo.getId());
IdmPasswordDto passwordTwo = passwordService.find(filter, null).getContent().get(0);
filter.setIdentityId(identityTree.getId());
IdmPasswordDto passwordThree = passwordService.find(filter, null).getContent().get(0);
passwordOne.setValidTill(LocalDate.now().minusDays(1));
passwordTwo.setValidTill(LocalDate.now().minusDays(10));
passwordThree.setValidTill(LocalDate.now().minusDays(100));
passwordService.save(passwordOne);
passwordService.save(passwordTwo);
passwordService.save(passwordThree);
filter = new IdmPasswordFilter();
filter.setValidTill(LocalDate.now().minusDays(99));
List<IdmPasswordDto> passwords = passwordService.find(filter, null).getContent();
assertTrue(passwords.size() >= 1);
IdmPasswordDto passwordDto = passwords.stream().filter(pass -> {
return pass.getIdentity().equals(identityOne.getId());
}).findFirst().orElse(null);
assertNull(passwordDto);
passwordDto = passwords.stream().filter(pass -> {
return pass.getIdentity().equals(identityTwo.getId());
}).findFirst().orElse(null);
assertNull(passwordDto);
passwordDto = passwords.stream().filter(pass -> {
return pass.getIdentity().equals(identityTree.getId());
}).findFirst().orElse(null);
assertNotNull(passwordDto);
filter = new IdmPasswordFilter();
filter.setValidTill(LocalDate.now().minusDays(9));
passwords = passwordService.find(filter, null).getContent();
assertTrue(passwords.size() >= 2);
passwordDto = passwords.stream().filter(pass -> {
return pass.getIdentity().equals(identityOne.getId());
}).findFirst().orElse(null);
assertNull(passwordDto);
passwordDto = passwords.stream().filter(pass -> {
return pass.getIdentity().equals(identityTwo.getId());
}).findFirst().orElse(null);
assertNotNull(passwordDto);
passwordDto = passwords.stream().filter(pass -> {
return pass.getIdentity().equals(identityTree.getId());
}).findFirst().orElse(null);
assertNotNull(passwordDto);
filter = new IdmPasswordFilter();
filter.setValidTill(LocalDate.now());
passwords = passwordService.find(filter, null).getContent();
assertTrue(passwords.size() >= 2);
passwordDto = passwords.stream().filter(pass -> {
return pass.getIdentity().equals(identityOne.getId());
}).findFirst().orElse(null);
assertNotNull(passwordDto);
passwordDto = passwords.stream().filter(pass -> {
return pass.getIdentity().equals(identityTwo.getId());
}).findFirst().orElse(null);
assertNotNull(passwordDto);
passwordDto = passwords.stream().filter(pass -> {
return pass.getIdentity().equals(identityTree.getId());
}).findFirst().orElse(null);
assertNotNull(passwordDto);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmPasswordServiceIntegrationTest method testFilterIdentityUsername.
@Test
public void testFilterIdentityUsername() {
IdmIdentityDto identity = getHelper().createIdentity(new GuardedString("test" + System.currentTimeMillis()));
IdmPasswordFilter filter = new IdmPasswordFilter();
filter.setIdentityUsername(identity.getUsername());
List<IdmPasswordDto> passwords = passwordService.find(filter, null).getContent();
assertEquals(1, passwords.size());
IdmPasswordDto passwordDto = passwords.get(0);
assertEquals(identity.getId(), passwordDto.getIdentity());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmPasswordServiceIntegrationTest method testPreserveValidFromUnderSameIdentity.
@Test
public void testPreserveValidFromUnderSameIdentity() {
IdmIdentityDto identity = getHelper().createIdentity();
//
IdmPasswordDto password = passwordService.findOneByIdentity(identity.getId());
Assert.assertNull(password.getValidFrom());
Assert.assertEquals(identity.getId(), password.getIdentity());
//
PasswordChangeDto passwordChangeDto = new PasswordChangeDto();
passwordChangeDto.setAll(true);
passwordChangeDto.setIdm(true);
passwordChangeDto.setOldPassword(identity.getPassword());
passwordChangeDto.setNewPassword(new GuardedString("testPassword"));
passwordChangeDto.setSkipResetValidFrom(true);
//
try {
getHelper().login(identity);
identityService.passwordChange(identity, passwordChangeDto);
password = passwordService.findOneByIdentity(identity.getId());
Assert.assertNotNull(password.getValidFrom());
Assert.assertNull(password.getValidTill());
} finally {
logout();
}
}
use of eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmPasswordServiceIntegrationTest method checkNullBothPasswords.
@Test
public void checkNullBothPasswords() {
GuardedString passwordForCheck = new GuardedString();
IdmPasswordDto newPassword = new IdmPasswordDto();
assertFalse(passwordService.checkPassword(passwordForCheck, newPassword));
}
Aggregations