use of eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleAttributeDto in project CzechIdMng by bcvsolutions.
the class IdmAutomaticRoleAttributeController method deleteViaRequest.
@ResponseBody
@RequestMapping(value = "/delete-via-request/{backendId}", method = RequestMethod.DELETE)
@PreAuthorize("hasAuthority('" + CoreGroupPermission.AUTOMATIC_ROLE_ATTRIBUTE_DELETE + "')")
@ApiOperation(value = "Delete automatic role by attribute. Uses request.", nickname = "deleteAutomaticRoleAttributeViaRequest", tags = { IdmAutomaticRoleAttributeController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = CoreGroupPermission.AUTOMATIC_ROLE_ATTRIBUTE_DELETE, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = CoreGroupPermission.AUTOMATIC_ROLE_ATTRIBUTE_DELETE, description = "") }) })
public ResponseEntity<?> deleteViaRequest(@ApiParam(value = "Automatic role's uuid identifier.", required = true) @PathVariable @NotNull String backendId) {
IdmAutomaticRoleAttributeDto automaticRole = this.getDto(backendId);
Assert.notNull(automaticRole);
requestService.deleteAutomaticRole(automaticRole, AutomaticRoleRequestType.ATTRIBUTE);
throw new AcceptedException();
}
use of eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleAttributeDto in project CzechIdMng by bcvsolutions.
the class DefaultTestHelper method createAutomaticRole.
@Override
public IdmAutomaticRoleAttributeDto createAutomaticRole(UUID roleId) {
String testName = "test-auto-role-" + System.currentTimeMillis();
if (roleId == null) {
IdmRoleDto role = this.createRole();
roleId = role.getId();
}
IdmAutomaticRoleAttributeDto automaticRole = new IdmAutomaticRoleAttributeDto();
automaticRole.setRole(roleId);
automaticRole.setName(testName);
return automaticRoleAttributeService.save(automaticRole);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleAttributeDto in project CzechIdMng by bcvsolutions.
the class DefaultTestHelper method createAutomaticRoleRule.
@Override
public IdmAutomaticRoleAttributeRuleDto createAutomaticRoleRule(UUID automaticRoleId, AutomaticRoleAttributeRuleComparison comparsion, AutomaticRoleAttributeRuleType type, String attrName, UUID formAttrId, String value) {
IdmAutomaticRoleAttributeRuleDto rule = new IdmAutomaticRoleAttributeRuleDto();
rule.setComparison(comparsion);
rule.setType(type);
rule.setAttributeName(attrName);
rule.setFormAttribute(formAttrId);
rule.setValue(value);
rule.setAutomaticRoleAttribute(automaticRoleId);
rule = automaticRoleAttributeRuleService.save(rule);
// disable concept must be after rule save
IdmAutomaticRoleAttributeDto automaticRole = automaticRoleAttributeService.get(automaticRoleId);
automaticRole.setConcept(false);
automaticRole = automaticRoleAttributeService.save(automaticRole);
//
return rule;
}
use of eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleAttributeDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmAutomaticRoleAttributeIntegrationTest method testRemoveLastRuleWithoutCheck.
@Test
public void testRemoveLastRuleWithoutCheck() {
String eavCode = "testingEav";
Long testEavIdentityValue = System.currentTimeMillis();
UUID testEavContractValue = UUID.randomUUID();
IdmIdentityDto identity = testHelper.createIdentity();
IdmRoleDto role = testHelper.createRole();
IdmIdentityContractDto primeContract = testHelper.getPrimeContract(identity.getId());
// create two eav attributes (for identity and contract)
IdmFormAttributeDto eavAttributeIdentity = testHelper.createEavAttribute(eavCode + System.currentTimeMillis(), IdmIdentity.class, PersistentType.LONG);
testHelper.setEavValue(identity, eavAttributeIdentity, IdmIdentity.class, testEavIdentityValue, PersistentType.LONG);
IdmFormAttributeDto eavAttributeContract = testHelper.createEavAttribute(eavCode + System.currentTimeMillis(), IdmIdentityContract.class, PersistentType.UUID);
testHelper.setEavValue(primeContract, eavAttributeContract, IdmIdentityContract.class, testEavContractValue, PersistentType.UUID);
IdmAutomaticRoleAttributeDto automaticRole = testHelper.createAutomaticRole(role.getId());
IdmAutomaticRoleAttributeRuleDto rule1 = testHelper.createAutomaticRoleRule(automaticRole.getId(), AutomaticRoleAttributeRuleComparison.EQUALS, AutomaticRoleAttributeRuleType.IDENTITY_EAV, null, eavAttributeIdentity.getId(), testEavIdentityValue.toString());
IdmAutomaticRoleAttributeRuleDto rule2 = testHelper.createAutomaticRoleRule(automaticRole.getId(), AutomaticRoleAttributeRuleComparison.EQUALS, AutomaticRoleAttributeRuleType.CONTRACT_EAV, null, eavAttributeContract.getId(), testEavContractValue.toString());
List<IdmIdentityRoleDto> identityRoles = identityRoleService.findAllByIdentity(identity.getId());
assertEquals(0, identityRoles.size());
this.recalculateSync(automaticRole.getId());
identityRoles = identityRoleService.findAllByIdentity(identity.getId());
assertEquals(1, identityRoles.size());
automaticRoleAttributeRuleService.delete(rule1);
this.recalculateSync(automaticRole.getId());
identityRoles = identityRoleService.findAllByIdentity(identity.getId());
assertEquals(1, identityRoles.size());
automaticRoleAttributeRuleService.delete(rule2);
// in this case we not able remove the last automatic role from identity
identityRoles = identityRoleService.findAllByIdentity(identity.getId());
assertEquals(0, identityRoles.size());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleAttributeDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmAutomaticRoleAttributeIntegrationTest method testAutomaticRoleCrud.
@Test
public void testAutomaticRoleCrud() {
IdmRoleDto role = testHelper.createRole();
IdmAutomaticRoleAttributeDto automaticRole = new IdmAutomaticRoleAttributeDto();
automaticRole.setRole(role.getId());
automaticRole.setName(getTestName());
IdmAutomaticRoleAttributeDto savedAutomaticRole = automaticRoleAttributeService.save(automaticRole);
//
assertNotNull(savedAutomaticRole);
assertNotNull(savedAutomaticRole.getId());
assertEquals(automaticRole.getRole(), savedAutomaticRole.getRole());
assertEquals(automaticRole.getName(), savedAutomaticRole.getName());
//
try {
// update isn't allowed
savedAutomaticRole.setName(getTestName());
automaticRoleAttributeService.save(savedAutomaticRole);
fail();
} catch (Exception e) {
// success
}
//
automaticRoleAttributeService.delete(savedAutomaticRole);
//
IdmAutomaticRoleAttributeDto automaticRoleNull = automaticRoleAttributeService.get(savedAutomaticRole.getId());
assertNull(automaticRoleNull);
}
Aggregations