Search in sources :

Example 96 with IdmIdentityDto

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

the class AccountProtectionSystemTest method deleteAccountOnProtectionSystemTest.

@Test
public void deleteAccountOnProtectionSystemTest() {
    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);
    // Assign the role
    helper.createIdentityRole(identity, roleOne);
    AccAccountDto account = accountService.getAccount(identity.getUsername(), system.getId());
    AccIdentityAccountFilter identityAccountFilter = new AccIdentityAccountFilter();
    identityAccountFilter.setAccountId(account.getId());
    List<AccIdentityAccountDto> identityAccounts = identityAccountService.find(identityAccountFilter, null).getContent();
    // Identity account have relation on the role
    Assert.assertEquals(1, identityAccounts.size());
    Assert.assertNotNull(identityAccounts.get(0).getIdentityRole());
    Assert.assertNotNull(account);
    Assert.assertFalse(account.isInProtection());
    TestResource createdAccount = helper.findResource(account.getUid());
    Assert.assertNotNull(createdAccount);
    Assert.assertEquals(identity.getFirstName(), createdAccount.getFirstname());
    // Remove account directly. Account must be transformed to the protection state.
    accountService.delete(account);
    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());
    // Identity account have not relation on the role now.
    identityAccounts = identityAccountService.find(identityAccountFilter, null).getContent();
    Assert.assertEquals(1, identityAccounts.size());
    Assert.assertNull(identityAccounts.get(0).getIdentityRole());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) 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) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 97 with IdmIdentityDto

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

the class CoreReferentialIntegrityIntegrationTest method testIdentityReferentialIntegrity.

@Test
public void testIdentityReferentialIntegrity() {
    IdmIdentityDto identity = new IdmIdentityDto();
    String username = "delete_test_" + System.currentTimeMillis();
    identity.setUsername(username);
    // confidential storage
    identity.setPassword(new GuardedString("heslo"));
    identity.setFirstName("Test");
    identity.setLastName("Identity");
    identity = identityService.save(identity);
    // accounts
    SysSystemDto system = new SysSystemDto();
    system.setName("system_" + System.currentTimeMillis());
    system = systemService.save(system);
    SysSystemEntityDto systemEntity = new SysSystemEntityDto();
    systemEntity.setUid("test_uid_" + System.currentTimeMillis());
    systemEntity.setEntityType(SystemEntityType.IDENTITY);
    systemEntity.setWish(true);
    systemEntity.setSystem(system.getId());
    systemEntity = systemEntityService.save(systemEntity);
    AccAccountDto account = new AccAccountDto();
    account.setSystem(system.getId());
    account.setSystemEntity(systemEntity.getId());
    account.setUid(systemEntity.getUid());
    account.setAccountType(AccountType.PERSONAL);
    account.setEntityType(SystemEntityType.IDENTITY);
    account = accountService.save(account);
    AccIdentityAccountDto identityAccount = new AccIdentityAccountDto();
    identityAccount.setIdentity(identity.getId());
    identityAccount.setAccount(account.getId());
    identityAccount.setOwnership(true);
    identityAccount = identityAccountService.save(identityAccount);
    assertNotNull(identityService.getByUsername(username));
    assertNotNull(identityAccountService.get(identityAccount.getId()));
    assertNotNull(accountService.get(account.getId()));
    identityService.delete(identity);
    assertNull(identityService.getByUsername(username));
    assertNull(identityAccountService.get(identityAccount.getId()));
    assertNull(accountService.get(account.getId()));
}
Also used : GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 98 with IdmIdentityDto

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

the class DefaultAccAccountServiceFilterTest method testAccountType.

@Test
public void testAccountType() {
    IdmIdentityDto identity = helper.createIdentity("test-" + System.currentTimeMillis());
    SysSystemDto system = helper.createTestResourceSystem(true);
    createAccount(system.getId(), identity.getId(), identity.getUsername(), AccountType.PERSONAL, false);
    IdmIdentityDto identity2 = helper.createIdentity("test-" + System.currentTimeMillis());
    SysSystemDto system2 = helper.createTestResourceSystem(true);
    AccAccountDto account2 = createAccount(system2.getId(), identity2.getId(), identity2.getUsername(), AccountType.TECHNICAL, false);
    AccAccountFilter testFilter = new AccAccountFilter();
    testFilter.setAccountType(account2.getAccountType());
    Page<AccAccountDto> pages = accAccountService.find(testFilter, null);
    assertEquals(1, pages.getTotalElements());
    assertEquals(account2.getId(), pages.getContent().get(0).getId());
}
Also used : AccAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 99 with IdmIdentityDto

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

the class DefaultAccAccountServiceFilterTest method testIdentityId.

@Test
public void testIdentityId() {
    IdmIdentityDto identity = helper.createIdentity("test-" + System.currentTimeMillis());
    SysSystemDto system = helper.createTestResourceSystem(true);
    createAccount(system.getId(), identity.getId(), identity.getUsername(), AccountType.PERSONAL, false);
    IdmIdentityDto identity2 = helper.createIdentity("test-" + System.currentTimeMillis());
    SysSystemDto system2 = helper.createTestResourceSystem(true);
    createAccount(system2.getId(), identity.getId(), identity.getUsername(), AccountType.PERSONAL, false);
    AccAccountDto account3 = createAccount(system2.getId(), identity2.getId(), identity2.getUsername(), AccountType.PERSONAL, false);
    AccAccountFilter testFilter = new AccAccountFilter();
    testFilter.setIdentityId(identity2.getId());
    Page<AccAccountDto> pages = accAccountService.find(testFilter, null);
    assertEquals(1, pages.getTotalElements());
    assertEquals(account3.getId(), pages.getContent().get(0).getId());
}
Also used : AccAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 100 with IdmIdentityDto

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

the class DefaultAccAccountServiceFilterTest method testSupportChangePassword.

@Test
public void testSupportChangePassword() {
    IdmIdentityDto identity = helper.createIdentity("test-" + System.currentTimeMillis());
    SysSystemDto system = helper.createTestResourceSystem(true);
    AccAccountDto account = createAccount(system.getId(), identity.getId(), identity.getUsername(), AccountType.PERSONAL, false);
    IdmIdentityDto identity2 = helper.createIdentity("test-" + System.currentTimeMillis());
    SysSystemDto system2 = helper.createTestResourceSystem(true);
    createAccount(system2.getId(), identity2.getId(), identity2.getUsername(), AccountType.PERSONAL, false);
    AccAccountFilter testFilter = new AccAccountFilter();
    testFilter.setUid(identity.getUsername());
    testFilter.setSupportChangePassword(true);
    Page<AccAccountDto> pages = accAccountService.find(testFilter, null);
    assertEquals(1, pages.getTotalElements());
    assertEquals(account.getId(), pages.getContent().get(0).getId());
    // 
    SysSystemMappingDto defaultMapping = helper.getDefaultMapping(system);
    List<SysSystemAttributeMappingDto> attributes = attributeMappingService.findBySystemMapping(defaultMapping);
    // 
    for (SysSystemAttributeMappingDto attr : attributes) {
        if (attr.getName().equals(IcConnectorFacade.PASSWORD_ATTRIBUTE_NAME)) {
            attributeMappingService.delete(attr);
        }
    }
    // 
    testFilter = new AccAccountFilter();
    testFilter.setUid(identity.getUsername());
    testFilter.setSupportChangePassword(true);
    pages = accAccountService.find(testFilter, null);
    assertEquals(0, pages.getTotalElements());
}
Also used : AccAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)568 Test (org.junit.Test)433 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)328 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)206 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)157 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)99 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)95 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)69 ArrayList (java.util.ArrayList)63 LoginDto (eu.bcvsolutions.idm.core.security.api.dto.LoginDto)61 UUID (java.util.UUID)59 AbstractCoreWorkflowIntegrationTest (eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest)58 AccIdentityAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)55 IdmRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto)54 IdmNotificationLogDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto)54 Transactional (org.springframework.transaction.annotation.Transactional)53 IdmNotificationFilter (eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter)51 AccIdentityAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter)50 IdmConceptRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto)49 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)48