use of eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto in project CzechIdMng by bcvsolutions.
the class ProvisioningBreakProcessorTest method testGlobalConfigurationOverride.
@Test
public void testGlobalConfigurationOverride() {
SysSystemDto system = testHelper.createTestResourceSystem(true);
IdmIdentityDto identity = testHelper.createIdentity();
IdmIdentityDto recipient = testHelper.createIdentity();
//
// create global configuration
createGlobalConfiguration(ProvisioningBreakConfiguration.GLOBAL_BREAK_UPDATE_OPERATION, false, null, 1, 20l, recipient, null);
//
SysProvisioningBreakConfigDto breakConfig = createProvisioningBreak(20l, 3, null, ProvisioningEventType.UPDATE, system.getId());
IdmIdentityDto recipient2 = testHelper.createIdentity();
createRecipient(breakConfig.getId(), recipient2.getId(), null);
//
this.createAccount(system, identity);
//
// create
provisioningService.doProvisioning(identity);
provisioningService.doProvisioning(identity);
provisioningService.doProvisioning(identity);
provisioningService.doProvisioning(identity);
//
IdmNotificationFilter filter = new IdmNotificationFilter();
filter.setRecipient(recipient.getUsername());
List<IdmNotificationLogDto> content = notificationLogService.find(filter, null).getContent();
assertEquals(0, content.size());
//
system = systemService.get(system.getId());
assertNotEquals(Boolean.TRUE, system.getBlockedOperation().getUpdateOperation());
assertNotEquals(Boolean.TRUE, system.getBlockedOperation().getCreateOperation());
assertNotEquals(Boolean.TRUE, system.getBlockedOperation().getDeleteOperation());
//
// block
provisioningService.doProvisioning(identity);
//
filter = new IdmNotificationFilter();
filter.setRecipient(recipient.getUsername());
content = notificationLogService.find(filter, null).getContent();
assertEquals(0, content.size());
//
filter = new IdmNotificationFilter();
filter.setRecipient(recipient2.getUsername());
content = notificationLogService.find(filter, null).getContent();
// two notification (notification +
assertEquals(2, content.size());
// parent)
//
system = systemService.get(system.getId());
assertEquals(Boolean.TRUE, system.getBlockedOperation().getUpdateOperation());
assertNotEquals(Boolean.TRUE, system.getBlockedOperation().getCreateOperation());
assertNotEquals(Boolean.TRUE, system.getBlockedOperation().getDeleteOperation());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto in project CzechIdMng by bcvsolutions.
the class ProvisioningBreakProcessorTest method testDisableUpdateOperation.
@Test
public void testDisableUpdateOperation() {
SysSystemDto system = testHelper.createTestResourceSystem(true);
IdmIdentityDto identity = testHelper.createIdentity();
SysProvisioningBreakConfigDto breakConfig = createProvisioningBreak(20l, 2, null, ProvisioningEventType.UPDATE, system.getId());
IdmIdentityDto recipient = testHelper.createIdentity();
createRecipient(breakConfig.getId(), recipient.getId(), null);
//
this.createAccount(system, identity);
//
//
// create
provisioningService.doProvisioning(identity);
provisioningService.doProvisioning(identity);
provisioningService.doProvisioning(identity);
provisioningService.doProvisioning(identity);
//
IdmNotificationFilter filter = new IdmNotificationFilter();
filter.setRecipient(recipient.getUsername());
List<IdmNotificationLogDto> content = notificationLogService.find(filter, null).getContent();
// two notification (notification +
assertEquals(2, content.size());
// parent)
//
system = systemService.get(system.getId());
assertEquals(Boolean.TRUE, system.getBlockedOperation().getUpdateOperation());
assertNotEquals(Boolean.TRUE, system.getBlockedOperation().getCreateOperation());
assertNotEquals(Boolean.TRUE, system.getBlockedOperation().getDeleteOperation());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto in project CzechIdMng by bcvsolutions.
the class ProvisioningBreakProcessorTest method testPeriodOld.
@Test
public void testPeriodOld() {
SysSystemDto system = testHelper.createTestResourceSystem(true);
IdmIdentityDto identity = testHelper.createIdentity();
SysProvisioningBreakConfigDto breakConfig = createProvisioningBreak(20l, 3, null, ProvisioningEventType.UPDATE, system.getId());
IdmIdentityDto recipient = testHelper.createIdentity();
createRecipient(breakConfig.getId(), recipient.getId(), null);
//
this.createAccount(system, identity);
//
//
// create
provisioningService.doProvisioning(identity);
provisioningService.doProvisioning(identity);
provisioningService.doProvisioning(identity);
//
SysSystemEntityDto systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, identity.getUsername());
SysProvisioningBatchDto batch = batchService.findBatch(system.getId(), identity.getId(), systemEntity.getId());
//
assertNull(batch);
//
SysProvisioningBreakItems cacheProcessedItems = provisioningBreakConfig.getCacheProcessedItems(system.getId());
//
// subtrack 25 minutes from all items
long subtrackMinutes = 1500000;
List<Long> execudedItems = cacheProcessedItems.getExecutedItems(ProvisioningEventType.UPDATE);
// it isn't possible use foreEach or another stream function (reference)
for (Long item : execudedItems) {
execudedItems.set(execudedItems.indexOf(item), item - subtrackMinutes);
}
//
provisioningService.doProvisioning(identity);
provisioningService.doProvisioning(identity);
//
systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, identity.getUsername());
batch = batchService.findBatch(system.getId(), identity.getId(), systemEntity.getId());
//
assertNull(batch);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto in project CzechIdMng by bcvsolutions.
the class ProvisioningBreakProcessorTest method testWarningCreateOperation.
@Test
public void testWarningCreateOperation() {
SysSystemDto system = testHelper.createTestResourceSystem(true);
IdmIdentityDto identity = testHelper.createIdentity();
IdmIdentityDto identity2 = testHelper.createIdentity();
IdmIdentityDto identity3 = testHelper.createIdentity();
SysProvisioningBreakConfigDto breakConfig = createProvisioningBreak(20l, null, 2, ProvisioningEventType.CREATE, system.getId());
IdmIdentityDto recipient = testHelper.createIdentity();
createRecipient(breakConfig.getId(), recipient.getId(), null);
//
this.createAccount(system, identity);
this.createAccount(system, identity2);
this.createAccount(system, identity3);
//
provisioningService.doProvisioning(identity);
provisioningService.doProvisioning(identity2);
provisioningService.doProvisioning(identity3);
//
IdmNotificationFilter filter = new IdmNotificationFilter();
filter.setRecipient(recipient.getUsername());
List<IdmNotificationLogDto> content = notificationLogService.find(filter, null).getContent();
// two notification (notification +
assertEquals(2, content.size());
// parent)
//
system = systemService.get(system.getId());
assertNotEquals(Boolean.TRUE, system.getBlockedOperation().getUpdateOperation());
assertNotEquals(Boolean.TRUE, system.getBlockedOperation().getCreateOperation());
assertNotEquals(Boolean.TRUE, system.getBlockedOperation().getDeleteOperation());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto in project CzechIdMng by bcvsolutions.
the class ProvisioningBreakProcessorTest method testGlobalConfigurationSettings.
@Test
public void testGlobalConfigurationSettings() {
IdmIdentityDto recipient = testHelper.createIdentity();
IdmIdentityDto recipient2 = testHelper.createIdentity();
IdmRoleDto roleRecipient = testHelper.createRole();
//
createGlobalConfiguration(ProvisioningBreakConfiguration.GLOBAL_BREAK_DELETE_OPERATION, false, 2, 3, 20l, null, roleRecipient);
String prefix = ProvisioningBreakConfiguration.GLOBAL_BREAK_PREFIX + ProvisioningBreakConfiguration.GLOBAL_BREAK_DELETE_OPERATION;
configurationService.setValue(prefix + ProvisioningBreakConfiguration.PROPERTY_IDENTITY_RECIPIENTS, recipient.getUsername() + ", " + recipient2.getUsername());
//
// check non existing configuration
ProvisioningEventType eventType = ProvisioningEventType.UPDATE;
Object value = provisioningBreakConfiguration.getDisabled(eventType);
assertNull(value);
value = provisioningBreakConfiguration.getDisableLimit(eventType);
assertNull(value);
List<IdmIdentityDto> recipients = provisioningBreakConfiguration.getIdentityRecipients(eventType);
assertTrue(recipients.isEmpty());
value = provisioningBreakConfiguration.getPeriod(eventType);
assertNull(value);
//
// check existing
eventType = ProvisioningEventType.DELETE;
Boolean disabled = provisioningBreakConfiguration.getDisabled(eventType);
Integer warningLimit = provisioningBreakConfiguration.getWarningLimit(eventType);
Integer disableLimit = provisioningBreakConfiguration.getDisableLimit(eventType);
Long period = provisioningBreakConfiguration.getPeriod(eventType);
List<IdmIdentityDto> identityRecipients = provisioningBreakConfiguration.getIdentityRecipients(eventType);
List<IdmRoleDto> roleRecipients = provisioningBreakConfiguration.getRoleRecipients(eventType);
//
assertEquals(Boolean.FALSE, disabled);
assertEquals(Integer.valueOf(2), warningLimit);
assertEquals(Integer.valueOf(3), disableLimit);
assertEquals(Long.valueOf(20l), period);
assertEquals(2, identityRecipients.size());
assertEquals(1, roleRecipients.size());
//
IdmIdentityDto foundedRecipient = identityRecipients.stream().filter(rec -> rec.getUsername().equals(recipient.getUsername())).findFirst().get();
assertNotNull(foundedRecipient);
assertEquals(recipient.getId(), foundedRecipient.getId());
//
foundedRecipient = identityRecipients.stream().filter(rec -> rec.getUsername().equals(recipient2.getUsername())).findFirst().get();
assertNotNull(foundedRecipient);
assertEquals(recipient2.getId(), foundedRecipient.getId());
//
IdmRoleDto foundedRole = roleRecipients.get(0);
assertNotNull(foundedRole);
assertEquals(roleRecipient.getId(), foundedRole.getId());
}
Aggregations