Search in sources :

Example 26 with AccAccountDto

use of eu.bcvsolutions.idm.acc.dto.AccAccountDto 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 27 with AccAccountDto

use of eu.bcvsolutions.idm.acc.dto.AccAccountDto 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 28 with AccAccountDto

use of eu.bcvsolutions.idm.acc.dto.AccAccountDto in project CzechIdMng by bcvsolutions.

the class DefaultAccAccountServiceFilterTest method createAccount.

private AccAccountDto createAccount(UUID systemId, UUID identityId, String uid, AccountType accountType, Boolean ownership) {
    AccAccountDto account = new AccAccountDto();
    account.setSystem(systemId);
    account.setUid(uid);
    account.setAccountType(accountType);
    account = accAccountService.save(account);
    AccIdentityAccountDto accountIdentity = new AccIdentityAccountDto();
    accountIdentity.setIdentity(identityId);
    accountIdentity.setOwnership(ownership);
    accountIdentity.setAccount(account.getId());
    identityAccoutnService.save(accountIdentity);
    return account;
}
Also used : AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)

Example 29 with AccAccountDto

use of eu.bcvsolutions.idm.acc.dto.AccAccountDto in project CzechIdMng by bcvsolutions.

the class DefaultAccAccountServiceFilterTest method testEventType.

@Test
public void testEventType() {
    SysSystemDto system = helper.createTestResourceSystem(true);
    AccAccountDto accountOne = new AccAccountDto();
    accountOne.setSystem(system.getId());
    accountOne.setUid(UUID.randomUUID().toString());
    accountOne.setAccountType(AccountType.PERSONAL);
    accountOne.setEntityType(SystemEntityType.IDENTITY);
    accountOne = accAccountService.save(accountOne);
    AccAccountDto accountTwo = new AccAccountDto();
    accountTwo.setSystem(system.getId());
    accountTwo.setUid(UUID.randomUUID().toString());
    accountTwo.setAccountType(AccountType.PERSONAL);
    accountTwo.setEntityType(SystemEntityType.ROLE);
    accountTwo = accAccountService.save(accountTwo);
    // 
    AccAccountFilter testFilter = new AccAccountFilter();
    testFilter.setId(accountOne.getId());
    testFilter.setEntityType(SystemEntityType.IDENTITY);
    List<AccAccountDto> accounts = accAccountService.find(testFilter, null).getContent();
    // 
    Assert.assertEquals(1, accounts.size());
    Assert.assertEquals(accountOne.getUid(), accounts.get(0).getUid());
    // 
    testFilter.setId(accountTwo.getId());
    accounts = accAccountService.find(testFilter, null).getContent();
    Assert.assertTrue(accounts.isEmpty());
}
Also used : AccAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 30 with AccAccountDto

use of eu.bcvsolutions.idm.acc.dto.AccAccountDto 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

AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)90 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)59 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)47 Test (org.junit.Test)45 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)44 AccIdentityAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)33 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)29 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)25 AccAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter)19 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)18 TestResource (eu.bcvsolutions.idm.acc.entity.TestResource)18 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)16 AccIdentityAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter)16 ArrayList (java.util.ArrayList)16 SysSyncItemLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto)15 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)14 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)14 UUID (java.util.UUID)14 SysSystemEntityDto (eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto)13 PasswordChangeDto (eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto)13