use of eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter in project CzechIdMng by bcvsolutions.
the class IdentityMonitoredFieldsProcessorTest method changeNotMonitoredFieldTest.
@Test
public void changeNotMonitoredFieldTest() {
configurationService.setValue(PROCESSOR_KEY + "enabled", Boolean.TRUE.toString());
configurationService.setValue(PROCESSOR_KEY + IdentityMonitoredFieldsProcessor.PROPERTY_MONITORED_FIELDS, "firstName");
configurationService.setValue(PROCESSOR_KEY + IdentityMonitoredFieldsProcessor.PROPERTY_RECIPIENTS_ROLE, "superAdminRole");
//
IdmIdentityDto identity = helper.createIdentity();
List<IdmIdentityDto> recipients = identityService.findAllByRoleName("superAdminRole");
Assert.notEmpty(recipients, "Test need some recipients");
// Test before notify
IdmNotificationFilter filter = new IdmNotificationFilter();
filter.setRecipient(recipients.get(0).getUsername());
String changedValue = "changed" + UUID.randomUUID();
// We change not monitored fields
identity.setLastName(changedValue);
identity.setDescription(changedValue);
identityService.save(identity);
// Test after notify
List<IdmNotificationLogDto> notifications = notificationLogService.find(filter, null).getContent().stream().filter(notification -> {
return notification.getTopic().equals(CoreModuleDescriptor.TOPIC_IDENTITY_MONITORED_CHANGED_FIELDS);
}).collect(Collectors.toList());
// No notification should be sent
assertEquals(0, notifications.size());
}
use of eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter in project CzechIdMng by bcvsolutions.
the class ProvisioningBreakProcessorTest method testGlobalConfigurationDisable.
@Test
public void testGlobalConfigurationDisable() {
SysSystemDto system = testHelper.createTestResourceSystem(true);
IdmIdentityDto identity = testHelper.createIdentity();
IdmIdentityDto recipient = testHelper.createIdentity();
//
// create global configuration
createGlobalConfiguration(ProvisioningBreakConfiguration.GLOBAL_BREAK_UPDATE_OPERATION, false, null, 2, 20l, recipient, null);
//
this.createAccount(system, identity);
//
// create
provisioningService.doProvisioning(identity);
provisioningService.doProvisioning(identity);
provisioningService.doProvisioning(identity);
// block
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.notification.api.dto.filter.IdmNotificationFilter in project CzechIdMng by bcvsolutions.
the class ProvisioningBreakProcessorTest method testDisableCreateOperation.
@Test
public void testDisableCreateOperation() {
SysSystemDto system = testHelper.createTestResourceSystem(true);
IdmIdentityDto identity = testHelper.createIdentity();
IdmIdentityDto identity2 = testHelper.createIdentity();
IdmIdentityDto identity3 = testHelper.createIdentity();
SysProvisioningBreakConfigDto breakConfig = createProvisioningBreak(20l, 2, null, 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());
assertEquals(Boolean.TRUE, system.getBlockedOperation().getCreateOperation());
assertNotEquals(Boolean.TRUE, system.getBlockedOperation().getDeleteOperation());
}
use of eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter in project CzechIdMng by bcvsolutions.
the class ProvisioningBreakProcessorTest method testDisableUpdateOperationWithZeroLimit.
@Test
public void testDisableUpdateOperationWithZeroLimit() {
SysSystemDto system = testHelper.createTestResourceSystem(true);
IdmIdentityDto identity = testHelper.createIdentity();
SysProvisioningBreakConfigDto breakConfig = createProvisioningBreak(20l, 0, 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);
//
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.notification.api.dto.filter.IdmNotificationFilter in project CzechIdMng by bcvsolutions.
the class IdentityMonitoredFieldsProcessorTest method sendNotificationErrorTest.
@Test(expected = ResultCodeException.class)
public void sendNotificationErrorTest() {
configurationService.setValue(PROCESSOR_KEY + "enabled", Boolean.TRUE.toString());
configurationService.setValue(PROCESSOR_KEY + IdentityMonitoredFieldsProcessor.PROPERTY_MONITORED_FIELDS, "firstName, WRONGFIELD");
configurationService.setValue(PROCESSOR_KEY + IdentityMonitoredFieldsProcessor.PROPERTY_RECIPIENTS_ROLE, "superAdminRole");
//
IdmIdentityDto identity = helper.createIdentity();
List<IdmIdentityDto> recipients = identityService.findAllByRoleName("superAdminRole");
Assert.notEmpty(recipients, "Test need some recipients");
// Test before notify
IdmNotificationFilter filter = new IdmNotificationFilter();
filter.setRecipient(recipients.get(0).getUsername());
String changedValue = "changed" + UUID.randomUUID();
identity.setFirstName(changedValue);
identityService.save(identity);
// Test after notify ... must be 0 ... processor is disabled
List<IdmNotificationLogDto> notifications = notificationLogService.find(filter, null).getContent().stream().filter(notification -> {
return notification.getTopic().equals(CoreModuleDescriptor.TOPIC_IDENTITY_MONITORED_CHANGED_FIELDS);
}).collect(Collectors.toList());
//
assertEquals(0, notifications.size());
}
Aggregations