use of eu.bcvsolutions.idm.acc.dto.SysSystemDto 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()));
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemDto 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());
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemDto 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());
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemDto 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());
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemDto 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());
}
Aggregations