Search in sources :

Example 11 with NotificationToEmailConverterCommon

use of com.yahoo.athenz.common.server.notification.NotificationToEmailConverterCommon in project athenz by yahoo.

the class ZMSNotificationTaskFactoryTest method testNotificationTasksOrdering.

@Test
public void testNotificationTasksOrdering() {
    DBService dbsvc = Mockito.mock(DBService.class);
    ZMSNotificationTaskFactory zmsNotificationTaskFactory = new ZMSNotificationTaskFactory(dbsvc, USER_DOMAIN_PREFIX, new NotificationToEmailConverterCommon(null));
    List<NotificationTask> notificationTasks = zmsNotificationTaskFactory.getNotificationTasks();
    assertEquals(5, notificationTasks.size());
    assertEquals(notificationTasks.get(0).getDescription(), "pending role membership approvals reminders");
    assertEquals(notificationTasks.get(1).getDescription(), "pending group membership approvals reminders");
    assertEquals(notificationTasks.get(2).getDescription(), "membership expiration reminders");
    assertEquals(notificationTasks.get(3).getDescription(), "Periodic Review Reminder");
    assertEquals(notificationTasks.get(4).getDescription(), "group membership expiration reminders");
}
Also used : DBService(com.yahoo.athenz.zms.DBService) NotificationTask(com.yahoo.athenz.common.server.notification.NotificationTask) NotificationToEmailConverterCommon(com.yahoo.athenz.common.server.notification.NotificationToEmailConverterCommon) Test(org.testng.annotations.Test)

Example 12 with NotificationToEmailConverterCommon

use of com.yahoo.athenz.common.server.notification.NotificationToEmailConverterCommon in project athenz by yahoo.

the class ZMSImpl method setNotificationManager.

private void setNotificationManager() {
    notificationToEmailConverterCommon = new NotificationToEmailConverterCommon(userAuthority);
    ZMSNotificationTaskFactory zmsNotificationTaskFactory = new ZMSNotificationTaskFactory(dbService, userDomainPrefix, notificationToEmailConverterCommon);
    notificationManager = new NotificationManager(zmsNotificationTaskFactory.getNotificationTasks(), userAuthority);
}
Also used : NotificationToEmailConverterCommon(com.yahoo.athenz.common.server.notification.NotificationToEmailConverterCommon) NotificationManager(com.yahoo.athenz.common.server.notification.NotificationManager) ZMSNotificationTaskFactory(com.yahoo.athenz.zms.notification.ZMSNotificationTaskFactory)

Example 13 with NotificationToEmailConverterCommon

use of com.yahoo.athenz.common.server.notification.NotificationToEmailConverterCommon in project athenz by yahoo.

the class CertFailedRefreshNotificationTaskTest method testGetEmailBodySingleRecord.

@Test
public void testGetEmailBodySingleRecord() {
    System.setProperty("athenz.notification_workflow_url", "https://athenz.example.com/workflow");
    System.setProperty("athenz.notification_support_text", "#Athenz slack channel");
    System.setProperty("athenz.notification_support_url", "https://link.to.athenz.channel.com");
    System.setProperty("athenz.notification_athenz_ui_url", "https://ui-athenz.example.com/");
    Map<String, String> details = new HashMap<>();
    details.put("domain", "dom1");
    details.put(NOTIFICATION_DETAILS_UNREFRESHED_CERTS, "service1;provider1;instanceid1;Sun Mar 15 15:08:07 IST 2020;;hostName1");
    Notification notification = new Notification();
    notification.setDetails(details);
    CertFailedRefreshNotificationTask.CertFailedRefreshNotificationToEmailConverter converter = new CertFailedRefreshNotificationTask.CertFailedRefreshNotificationToEmailConverter(serverName, httpsPort, new NotificationToEmailConverterCommon(null));
    NotificationEmail notificationAsEmail = converter.getNotificationAsEmail(notification);
    String body = notificationAsEmail.getBody();
    assertNotNull(body);
    assertTrue(body.contains(htmlSingleRecord));
    System.clearProperty("athenz.notification_workflow_url");
    System.clearProperty("notification_support_text");
    System.clearProperty("notification_support_url");
    System.clearProperty("athenz.notification_athenz_ui_url");
}
Also used : NotificationEmail(com.yahoo.athenz.common.server.notification.NotificationEmail) NotificationToEmailConverterCommon(com.yahoo.athenz.common.server.notification.NotificationToEmailConverterCommon) Notification(com.yahoo.athenz.common.server.notification.Notification) Test(org.testng.annotations.Test)

Aggregations

NotificationToEmailConverterCommon (com.yahoo.athenz.common.server.notification.NotificationToEmailConverterCommon)13 Notification (com.yahoo.athenz.common.server.notification.Notification)8 Test (org.testng.annotations.Test)8 NotificationEmail (com.yahoo.athenz.common.server.notification.NotificationEmail)4 NotificationServiceConstants (com.yahoo.athenz.common.server.notification.NotificationServiceConstants)4 Timestamp (com.yahoo.rdl.Timestamp)4 java.util (java.util)4 Mockito (org.mockito.Mockito)4 AssertJUnit.assertEquals (org.testng.AssertJUnit.assertEquals)4 USER_DOMAIN_PREFIX (com.yahoo.athenz.common.ServerCommonConsts.USER_DOMAIN_PREFIX)3 com.yahoo.athenz.zms (com.yahoo.athenz.zms)3 ArgumentMatchers.eq (org.mockito.ArgumentMatchers.eq)3 AssertJUnit.assertTrue (org.testng.AssertJUnit.assertTrue)3 HostnameResolver (com.yahoo.athenz.common.server.dns.HostnameResolver)2 NotificationManager (com.yahoo.athenz.common.server.notification.NotificationManager)2 InstanceCertManager (com.yahoo.athenz.zts.cert.InstanceCertManager)2 DataStore (com.yahoo.athenz.zts.store.DataStore)2 BeforeClass (org.testng.annotations.BeforeClass)2 Authority (com.yahoo.athenz.auth.Authority)1 Principal (com.yahoo.athenz.auth.Principal)1