Search in sources :

Example 1 with TestResource

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);
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) AccountProtectionExpirationTaskExecutor(eu.bcvsolutions.idm.acc.scheduler.task.impl.AccountProtectionExpirationTaskExecutor) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) DateTime(org.joda.time.DateTime) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 2 with TestResource

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;
}
Also used : TestResource(eu.bcvsolutions.idm.acc.entity.TestResource)

Example 3 with TestResource

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());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) PasswordChangeDto(eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 4 with TestResource

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());
    }
}
Also used : TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with TestResource

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);
}
Also used : TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

TestResource (eu.bcvsolutions.idm.acc.entity.TestResource)96 Test (org.junit.Test)82 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)80 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)80 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)62 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)60 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)41 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)36 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)36 AccIdentityAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter)32 AccIdentityAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)30 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)30 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)28 ConfidentialString (eu.bcvsolutions.idm.core.security.api.domain.ConfidentialString)19 SysSchemaAttributeFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter)12 PasswordChangeDto (eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto)12 OperationResult (eu.bcvsolutions.idm.core.api.entity.OperationResult)12 SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)11 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)10 Transactional (org.springframework.transaction.annotation.Transactional)10