Search in sources :

Example 21 with IdmIdentityRoleDto

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

the class AccountProtectionSystemTest method accountWithoutProtectionTest.

@Test
public void accountWithoutProtectionTest() {
    IdmIdentityDto identity = helper.createIdentity();
    SysSystemDto system = initSystem();
    IdmIdentityRoleDto identityRole = helper.createIdentityRole(identity, roleService.getByCode(ROLE_ONE));
    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 from identity
    identityRoleService.deleteById(identityRole.getId());
    account = accountService.getAccount(identity.getUsername(), system.getId());
    Assert.assertNull(account);
    createdAccount = entityManager.find(TestResource.class, identity.getUsername());
    Assert.assertNull(createdAccount);
}
Also used : 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) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 22 with IdmIdentityRoleDto

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

the class AccountProtectionSystemTest method accountWithProtectionAndIntervalTest.

@Test
public void accountWithProtectionAndIntervalTest() {
    IdmIdentityDto identity = helper.createIdentity();
    SysSystemDto system = initSystem();
    IdmRoleDto roleOne = roleService.getByCode(ROLE_ONE);
    int intervalInDays = 10;
    // Set system to protected mode
    SysSystemMappingDto mapping = systemMappingService.findBySystem(system, SystemOperationType.PROVISIONING, SystemEntityType.IDENTITY).get(0);
    mapping.setProtectionEnabled(Boolean.TRUE);
    mapping.setProtectionInterval(intervalInDays);
    mapping = systemMappingService.save(mapping);
    IdmIdentityRoleDto identityRole = helper.createIdentityRole(identity, roleOne);
    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 from identity
    identityRoleService.deleteById(identityRole.getId());
    account = accountService.getAccount(identity.getUsername(), system.getId());
    Assert.assertNotNull(account);
    Assert.assertTrue(account.isInProtection());
    Assert.assertNotNull(account.getEndOfProtection());
    Assert.assertTrue(account.getEndOfProtection().toLocalDate().isEqual(LocalDate.now().plusDays(intervalInDays)));
    createdAccount = helper.findResource(account.getUid());
    Assert.assertNotNull(createdAccount);
    Assert.assertEquals(identity.getFirstName(), createdAccount.getFirstname());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) 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) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 23 with IdmIdentityRoleDto

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

the class AccountProtectionSystemTest method accountWithProtectionTest.

@Test
public void accountWithProtectionTest() {
    IdmIdentityDto identity = helper.createIdentity();
    SysSystemDto system = initSystem();
    IdmRoleDto roleOne = roleService.getByCode(ROLE_ONE);
    // Set system to protected mode
    SysSystemMappingDto mapping = systemMappingService.findBySystem(system, SystemOperationType.PROVISIONING, SystemEntityType.IDENTITY).get(0);
    mapping.setProtectionEnabled(Boolean.TRUE);
    mapping.setProtectionInterval(null);
    systemMappingService.save(mapping);
    IdmIdentityRoleDto identityRole = helper.createIdentityRole(identity, roleOne);
    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 from identity
    identityRoleService.deleteById(identityRole.getId());
    account = accountService.getAccount(identity.getUsername(), system.getId());
    Assert.assertNotNull(account);
    Assert.assertTrue(account.isInProtection());
    Assert.assertNull(account.getEndOfProtection());
    createdAccount = helper.findResource(account.getUid());
    Assert.assertNotNull(createdAccount);
    Assert.assertEquals(identity.getFirstName(), createdAccount.getFirstname());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) 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) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 24 with IdmIdentityRoleDto

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

the class HrEndContractProcessIntegrationTest method addRolesToContract.

private void addRolesToContract(IdmIdentityContractDto contract) {
    roleService.find(new PageRequest(0, 5)).forEach(role -> {
        IdmIdentityRoleDto d = new IdmIdentityRoleDto();
        d.setRole(role.getId());
        d.setAutomaticRole(false);
        d.setIdentityContract(contract.getId());
        identityRoleService.save(d);
    });
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)

Example 25 with IdmIdentityRoleDto

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

the class DefaultAuthorizationManagerIntegrationTest method testFindValidPoliciesWithInvalidIdentityRole.

@Test
@Transactional
public void testFindValidPoliciesWithInvalidIdentityRole() {
    try {
        loginAsAdmin(InitTestData.TEST_USER_1);
        // prepare role
        IdmRoleDto role = helper.createRole();
        IdmRoleDto role2 = helper.createRole();
        helper.createUuidPolicy(role.getId(), role.getId(), IdmBasePermission.READ);
        helper.createBasePolicy(role2.getId(), IdmBasePermission.AUTOCOMPLETE);
        // prepare identity
        IdmIdentityDto identity = helper.createIdentity();
        // assign role
        helper.createIdentityRole(identity, role);
        IdmIdentityRoleDto assignedRole = helper.createIdentityRole(identity, role2);
        assignedRole.setValidFrom(new LocalDate().plusDays(1));
        identityRoleService.save(assignedRole);
        // 
        List<IdmAuthorizationPolicyDto> policies = service.getEnabledPolicies(identity.getId(), IdmRole.class);
        assertEquals(1, policies.size());
        assertEquals(role.getId(), policies.get(0).getRole());
    } finally {
        logout();
    }
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmAuthorizationPolicyDto(eu.bcvsolutions.idm.core.api.dto.IdmAuthorizationPolicyDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) LocalDate(org.joda.time.LocalDate) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)122 Test (org.junit.Test)94 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)90 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)72 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)71 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)54 IdmAutomaticRoleAttributeDto (eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleAttributeDto)30 LocalDate (org.joda.time.LocalDate)21 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)19 TestResource (eu.bcvsolutions.idm.acc.entity.TestResource)16 IdmFormAttributeDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto)15 AccIdentityAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter)13 UUID (java.util.UUID)13 AbstractUnitTest (eu.bcvsolutions.idm.test.api.AbstractUnitTest)12 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)11 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)10 Transactional (org.springframework.transaction.annotation.Transactional)10 AccIdentityAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)9 IdmIdentityRoleFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter)8 AbstractCoreWorkflowIntegrationTest (eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest)7