use of eu.bcvsolutions.idm.acc.entity.TestResource in project CzechIdMng by bcvsolutions.
the class AccountProtectionExpirationTaskExecutorIntegrationTest method testRemoveExpiredAccount.
@Test
public void testRemoveExpiredAccount() {
IdmIdentityDto identity = helper.createIdentity();
IdmRoleDto role = helper.createRole();
SysSystemDto system = helper.createTestResourceSystem(true);
SysSystemMappingDto mapping = helper.getDefaultMapping(system);
mapping.setProtectionInterval(1);
mapping.setProtectionEnabled(true);
systemMappingService.save(mapping);
helper.createRoleSystem(role, system);
IdmIdentityRoleDto identityRole = helper.createIdentityRole(identity, role);
//
AccAccountDto account = accountService.getAccount(identity.getUsername(), system.getId());
Assert.assertNotNull(account);
Assert.assertFalse(account.isInProtection());
TestResource createdAccount = helper.findResource(account.getUid());
Assert.assertNotNull(createdAccount);
Assert.assertEquals(identity.getFirstName(), createdAccount.getFirstname());
//
// remove role
identityRoleService.deleteById(identityRole.getId());
//
account = accountService.getAccount(identity.getUsername(), system.getId());
Assert.assertNotNull(account);
Assert.assertTrue(account.isInProtection());
Assert.assertNotNull(account.getEndOfProtection());
createdAccount = helper.findResource(account.getUid());
Assert.assertNotNull(createdAccount);
Assert.assertEquals(identity.getFirstName(), createdAccount.getFirstname());
//
// test LRT - nothing to remove
AccountProtectionExpirationTaskExecutor taskExecutor = new AccountProtectionExpirationTaskExecutor();
longRunningTaskManager.execute(taskExecutor);
//
account = accountService.getAccount(identity.getUsername(), system.getId());
Assert.assertNotNull(account);
Assert.assertTrue(account.isInProtection());
Assert.assertNotNull(account.getEndOfProtection());
createdAccount = helper.findResource(account.getUid());
Assert.assertNotNull(createdAccount);
Assert.assertEquals(identity.getFirstName(), createdAccount.getFirstname());
// change account expiration
account.setEndOfProtection(new DateTime().minusDays(1));
account = accountService.save(account);
taskExecutor = new AccountProtectionExpirationTaskExecutor();
longRunningTaskManager.execute(taskExecutor);
AccAccountDto removedAccount = accountService.getAccount(identity.getUsername(), system.getId());
Assert.assertNull(removedAccount);
createdAccount = helper.findResource(account.getUid());
Assert.assertNull(createdAccount);
}
use of eu.bcvsolutions.idm.acc.entity.TestResource in project CzechIdMng by bcvsolutions.
the class DefaultAccAccountServiceTest method createResource.
private TestResource createResource(String code, LocalDateTime modified) {
TestResource resource = new TestResource();
resource.setName(code);
resource.setEmail(code);
resource.setDescrip(code);
resource.setFirstname(code);
resource.setLastname(code);
resource.setModified(modified);
resource.setStatus(code);
resource.setEavAttribute(code);
return resource;
}
use of eu.bcvsolutions.idm.acc.entity.TestResource in project CzechIdMng by bcvsolutions.
the class IdentitySetPasswordProcessorIntegrationTest method testGeneratePassword.
@Test
public void testGeneratePassword() {
SysSystemDto system = helper.createTestResourceSystem(true);
//
IdmRoleDto role = helper.createRole();
helper.createRoleSystem(role, system);
IdmIdentityDto identity = helper.createIdentity();
IdmIdentityContractDto contract = helper.getPrimeContract(identity.getId());
contract.setValidFrom(LocalDate.now().plusDays(1));
identityContractService.save(contract);
identity = identityService.get(identity.getId());
Assert.assertEquals(IdentityState.FUTURE_CONTRACT, identity.getState());
helper.createIdentityRole(identity, role);
//
AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
filter.setIdentityId(identity.getId());
AccIdentityAccountDto accountIdentityOne = identityAccountService.find(filter, null).getContent().get(0);
AccAccountDto account = accountService.get(accountIdentityOne.getAccount());
// Create new password one
PasswordChangeDto passwordChange = new PasswordChangeDto();
passwordChange.setAccounts(ImmutableList.of(account.getId().toString()));
passwordChange.setNewPassword(new GuardedString(IDENTITY_PASSWORD_ONE));
passwordChange.setIdm(true);
//
// Do change of password for selected accounts
identityService.passwordChange(identity, passwordChange);
//
// Check correct password One
TestResource resource = helper.findResource(account.getRealUid());
Assert.assertNotNull(resource);
Assert.assertEquals(IDENTITY_PASSWORD_ONE, resource.getPassword());
//
// set contract to valid
contract.setValidFrom(LocalDate.now());
identityContractService.save(contract);
identity = identityService.get(identity.getId());
Assert.assertEquals(IdentityState.VALID, identity.getState());
//
// check password on target system was changed
resource = helper.findResource(account.getRealUid());
Assert.assertNotNull(resource);
Assert.assertNotEquals(IDENTITY_PASSWORD_ONE, resource.getPassword());
}
use of eu.bcvsolutions.idm.acc.entity.TestResource in project CzechIdMng by bcvsolutions.
the class ComplexHrProcessIntegrationTest method updateIdentityHRTable.
/*
* Updates existing record with the new values.
* If updated record doesn't exist an assertion is thrown
* Id is the primary key of the table i.e. extId Map key
*/
@Transactional
public void updateIdentityHRTable(String id, Map<String, String> identity) {
TestResource resource = entityManager.find(TestResource.class, id);
Assert.assertNotNull(resource);
if (identity.containsKey("extId")) {
// serves as Id
resource.setName(identity.get("extId"));
}
if (identity.containsKey("firstName")) {
resource.setFirstname(identity.get("firstName"));
}
if (identity.containsKey("lastName")) {
resource.setLastname(identity.get("lastName"));
}
if (identity.containsKey("titleBefore")) {
resource.setTitleBefore(identity.get("titleBefore"));
}
if (identity.containsKey("titleAfter")) {
resource.setTitleAfter(identity.get("titleAfter"));
}
if (identity.containsKey("personalNumber")) {
resource.setPersonalNumber(identity.get("personalNumber"));
}
if (!identity.isEmpty()) {
resource.setModified(ZonedDateTime.now());
}
}
use of eu.bcvsolutions.idm.acc.entity.TestResource in project CzechIdMng by bcvsolutions.
the class ComplexHrProcessIntegrationTest method addIdentityToHRTable.
/**
* Method for insertion of a new record into corresponding database table
*/
@Transactional
public void addIdentityToHRTable(Map<String, String> identity) {
TestResource resourceUserOne = new TestResource();
// serves as Id
resourceUserOne.setName(identity.get("extId"));
resourceUserOne.setFirstname(identity.get("firstName"));
resourceUserOne.setLastname(identity.get("lastName"));
resourceUserOne.setTitleBefore(identity.get("titleBefore"));
resourceUserOne.setTitleAfter(identity.get("titleAfter"));
resourceUserOne.setPersonalNumber(identity.get("personalNumber"));
resourceUserOne.setModified(ZonedDateTime.now());
entityManager.persist(resourceUserOne);
}
Aggregations