use of eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter in project CzechIdMng by bcvsolutions.
the class IdmNotificationConfigurationDisabledTest method testDisabledError.
@Test
@Transactional
public void testDisabledError() {
assertEquals(0, idmNotificationRepository.count());
NotificationLevel level = NotificationLevel.ERROR;
IdmNotificationTemplateDto template = createTestTemplate("Idm test notification", "disabled test");
IdmIdentityDto identity = getHelper().createIdentity("Test_disable_notifications" + System.currentTimeMillis());
configs.add(createNotificationConfiguration(TOPIC, level, IdmConsoleLog.NOTIFICATION_TYPE, template.getId(), true));
configs.add(createNotificationConfiguration(TOPIC, level, IdmEmailLog.NOTIFICATION_TYPE, template.getId(), true));
IdmMessageDto message = new IdmMessageDto();
message.setTemplate(template);
message.setLevel(level);
notificationManager.send(TOPIC, message, identity);
IdmNotificationFilter filter = new IdmNotificationFilter();
filter.setNotificationType(IdmNotificationLog.class);
assertEquals(0, notificationLogService.find(filter, null).getTotalElements());
deleteNotificationConfig();
}
use of eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter in project CzechIdMng by bcvsolutions.
the class IdmNotificationConfigurationDisabledTest method testOneDisabled.
@Test
@Transactional
public void testOneDisabled() {
assertEquals(0, idmNotificationRepository.count());
NotificationLevel level = NotificationLevel.ERROR;
IdmNotificationTemplateDto template = createTestTemplate("Idm test notification", "disabled test");
IdmIdentityDto identity = getHelper().createIdentity((GuardedString) null);
configs.add(createNotificationConfiguration(TOPIC, null, IdmConsoleLog.NOTIFICATION_TYPE, template.getId(), true));
configs.add(createNotificationConfiguration(TOPIC, null, IdmEmailLog.NOTIFICATION_TYPE, template.getId(), false));
IdmMessageDto message = new IdmMessageDto();
message.setTemplate(template);
message.setLevel(level);
notificationManager.send(TOPIC, message, identity);
IdmNotificationFilter filter = new IdmNotificationFilter();
filter.setNotificationType(IdmNotificationLog.class);
assertEquals(1, notificationLogService.find(filter, null).getTotalElements());
deleteNotificationConfig();
}
use of eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter in project CzechIdMng by bcvsolutions.
the class IdentityPasswordProvisioningTest method testSendPasswordNotificationProvisioningFailed.
@Test
public void testSendPasswordNotificationProvisioningFailed() {
SysSystemDto system = initSystem();
IdmRoleDto role = initRole(system);
IdmIdentityDto identity = helper.createIdentity();
// => new password is sent for valid identity only
identity.setState(IdentityState.VALID);
identityService.save(identity);
// Break the system (change the password column to not exists) - we need make a exception.
IdmFormDefinitionDto savedFormDefinition = systemService.getConnectorFormDefinition(system);
IdmFormAttributeDto formAttribute = savedFormDefinition.getMappedAttributeByCode("passwordColumn");
formService.saveValues(system, formAttribute, Lists.newArrayList("not-exist-column-password"));
IdmIdentityRoleDto identityRole = helper.createIdentityRole(identity, role);
checkIdentityAccount(identity, identityRole, 1);
AccAccountDto account = accountService.getAccount(identity.getUsername(), system.getId());
Assert.assertNotNull(account);
Assert.assertFalse(account.isInProtection());
TestResource entityOnSystem = helper.findResource(account.getUid());
assertNull(entityOnSystem);
// Check for send password notification
IdmNotificationFilter notificationFilter = new IdmNotificationFilter();
notificationFilter.setTopic(AccModuleDescriptor.TOPIC_NEW_PASSWORD);
notificationFilter.setRecipient(identity.getUsername());
List<IdmNotificationLogDto> notifications = //
notificationLogService.find(notificationFilter, null).getContent().stream().filter(//
notification -> IdmEmailLog.NOTIFICATION_TYPE.equals(notification.getType())).collect(Collectors.toList());
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 = getHelper().createTestResourceSystem(true);
IdmIdentityDto identity = getHelper().createIdentity((GuardedString) null);
IdmIdentityDto recipient = getHelper().createIdentity((GuardedString) null);
//
// 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 testDisableUpdateOperationWithZeroLimit.
@Test
public void testDisableUpdateOperationWithZeroLimit() {
SysSystemDto system = getHelper().createTestResourceSystem(true);
IdmIdentityDto identity = getHelper().createIdentity((GuardedString) null);
SysProvisioningBreakConfigDto breakConfig = createProvisioningBreak(20l, 0, null, ProvisioningEventType.UPDATE, system.getId());
IdmIdentityDto recipient = getHelper().createIdentity((GuardedString) null);
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());
}
Aggregations