use of eu.bcvsolutions.idm.acc.dto.AccAccountDto in project CzechIdMng by bcvsolutions.
the class DefaultAccAccountServiceFilterTest method testUid.
@Test
public void testUid() {
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(account.getUid());
Page<AccAccountDto> pages = accAccountService.find(testFilter, null);
assertEquals(1, pages.getTotalElements());
assertEquals(account.getId(), pages.getContent().get(0).getId());
}
use of eu.bcvsolutions.idm.acc.dto.AccAccountDto in project CzechIdMng by bcvsolutions.
the class DefaultAccAccountServiceFilterTest method testSystemEntityType.
@Test
public void testSystemEntityType() {
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.setEntityType(account.getEntityType());
testFilter.setSystemId(system.getId());
Page<AccAccountDto> pages = accAccountService.find(testFilter, null);
assertEquals(1, pages.getTotalElements());
assertEquals(account.getId(), pages.getContent().get(0).getId());
}
use of eu.bcvsolutions.idm.acc.dto.AccAccountDto in project CzechIdMng by bcvsolutions.
the class DefaultAccAccountServiceFilterTest method testSystemId.
@Test
public void testSystemId() {
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.setSystemId(system.getId());
Page<AccAccountDto> pages = accAccountService.find(testFilter, null);
assertEquals(1, pages.getTotalElements());
assertEquals(account.getId(), pages.getContent().get(0).getId());
}
use of eu.bcvsolutions.idm.acc.dto.AccAccountDto in project CzechIdMng by bcvsolutions.
the class DefaultAccAccountServiceFilterTest method testOwnership.
@Test
public void testOwnership() {
IdmIdentityDto identity = helper.createIdentity("test-" + System.currentTimeMillis());
SysSystemDto system = helper.createTestResourceSystem(true);
AccAccountDto account = createAccount(system.getId(), identity.getId(), identity.getUsername(), AccountType.PERSONAL, true);
createAccount(system.getId(), identity.getId(), identity.getUsername() + "2", AccountType.PERSONAL, false);
AccAccountFilter testFilter = new AccAccountFilter();
testFilter.setOwnership(true);
testFilter.setIdentityId(identity.getId());
Page<AccAccountDto> pages = accAccountService.find(testFilter, null);
assertEquals(1, pages.getTotalElements());
assertEquals(account.getId(), pages.getContent().get(0).getId());
}
use of eu.bcvsolutions.idm.acc.dto.AccAccountDto in project CzechIdMng by bcvsolutions.
the class DefaultAccAccountServiceTest method getConnectorObjectTest.
@Test
public void getConnectorObjectTest() {
String userOneName = "UserOne";
String eavAttributeName = "EAV_ATTRIBUTE";
SysSystemDto system = initData();
Assert.assertNotNull(system);
IdmIdentityDto identity = helper.createIdentity();
// Create role with evaluator
IdmRoleDto role = helper.createRole();
IdmAuthorizationPolicyDto policyAccount = new IdmAuthorizationPolicyDto();
policyAccount.setRole(role.getId());
policyAccount.setGroupPermission(AccGroupPermission.ACCOUNT.getName());
policyAccount.setAuthorizableType(AccAccount.class.getCanonicalName());
policyAccount.setEvaluator(ReadAccountByIdentityEvaluator.class);
authorizationPolicyService.save(policyAccount);
// Change resources (set state on exclude) .. must be call in transaction
this.getBean().persistResource(createResource(userOneName, new LocalDateTime()));
AccAccountDto account = new AccAccountDto();
account.setEntityType(SystemEntityType.IDENTITY);
account.setSystem(system.getId());
account.setAccountType(AccountType.PERSONAL);
account.setUid(userOneName);
account = accountService.save(account);
AccIdentityAccountDto accountIdentityOne = new AccIdentityAccountDto();
accountIdentityOne.setIdentity(identity.getId());
accountIdentityOne.setOwnership(true);
accountIdentityOne.setAccount(account.getId());
accountIdentityOne = identityAccountService.save(accountIdentityOne);
// Assign role with evaluator
helper.createIdentityRole(identity, role);
logout();
loginService.login(new LoginDto(identity.getUsername(), identity.getPassword()));
IcConnectorObject connectorObject = accountService.getConnectorObject(account, IdmBasePermission.READ);
Assert.assertNotNull(connectorObject);
Assert.assertEquals(userOneName, connectorObject.getUidValue());
Assert.assertNotNull(connectorObject.getAttributeByName(eavAttributeName));
Assert.assertEquals(userOneName, connectorObject.getAttributeByName(eavAttributeName).getValue());
}
Aggregations