Search in sources :

Example 6 with NotificationManager

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

the class DynamoDBCertRecordStoreTest method testEnableNotifications.

@Test
public void testEnableNotifications() {
    DynamoDBCertRecordStore store = new DynamoDBCertRecordStore(dbClient, "Athenz-ZTS-Table", "Athenz-ZTS-Current-Time-Index", "Athenz-ZTS-Host-Name-Index", null);
    boolean isEnabled = store.enableNotifications(null, null, null);
    assertFalse(isEnabled);
    ZTSClientNotificationSenderImpl ztsClientNotificationSender = new ZTSClientNotificationSenderImpl();
    store = new DynamoDBCertRecordStore(dbClient, "Athenz-ZTS-Table", "Athenz-ZTS-Current-Time-Index", "Athenz-ZTS-Host-Name-Index", ztsClientNotificationSender);
    isEnabled = store.enableNotifications(null, null, null);
    assertFalse(isEnabled);
    NotificationManager notificationManager = Mockito.mock(NotificationManager.class);
    RolesProvider rolesProvider = Mockito.mock(RolesProvider.class);
    String serverName = "testServer";
    isEnabled = store.enableNotifications(notificationManager, rolesProvider, serverName);
    assertTrue(isEnabled);
}
Also used : ZTSClientNotificationSenderImpl(com.yahoo.athenz.zts.notification.ZTSClientNotificationSenderImpl) NotificationManager(com.yahoo.athenz.common.server.notification.NotificationManager) RolesProvider(com.yahoo.athenz.common.server.db.RolesProvider) Test(org.testng.annotations.Test)

Example 7 with NotificationManager

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

the class DynamoDBSSHRecordStoreTest method testEnableNotifications.

@Test
public void testEnableNotifications() {
    DynamoDBSSHRecordStore store = new DynamoDBSSHRecordStore(dbClient, "Athenz-ZTS-Table", null);
    boolean isEnabled = store.enableNotifications(null, null, null);
    assertFalse(isEnabled);
    ZTSClientNotificationSenderImpl ztsClientNotificationSender = new ZTSClientNotificationSenderImpl();
    store = new DynamoDBSSHRecordStore(dbClient, "Athenz-ZTS-Table", ztsClientNotificationSender);
    isEnabled = store.enableNotifications(null, null, null);
    assertFalse(isEnabled);
    NotificationManager notificationManager = Mockito.mock(NotificationManager.class);
    RolesProvider rolesProvider = Mockito.mock(RolesProvider.class);
    String serverName = "testServer";
    isEnabled = store.enableNotifications(notificationManager, rolesProvider, serverName);
    assertTrue(isEnabled);
}
Also used : ZTSClientNotificationSenderImpl(com.yahoo.athenz.zts.notification.ZTSClientNotificationSenderImpl) NotificationManager(com.yahoo.athenz.common.server.notification.NotificationManager) RolesProvider(com.yahoo.athenz.common.server.db.RolesProvider) Test(org.testng.annotations.Test)

Example 8 with NotificationManager

use of com.yahoo.athenz.common.server.notification.NotificationManager 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 9 with NotificationManager

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

the class ZTSClientNotificationSenderImplTest method testInit.

@Test
public void testInit() {
    ZTSClientNotificationSenderImpl ztsClientNotificationSender = new ZTSClientNotificationSenderImpl();
    NotificationManager notificationManager = Mockito.mock(NotificationManager.class);
    Mockito.when(notificationManager.getNotificationUserAuthority()).thenReturn(Mockito.mock(Authority.class));
    RolesProvider rolesProvider = Mockito.mock(RolesProvider.class);
    String serverName = "testServer";
    boolean initResult = ztsClientNotificationSender.init(notificationManager, rolesProvider, serverName);
    assertTrue(initResult);
    initResult = ztsClientNotificationSender.init(notificationManager, rolesProvider, null);
    assertFalse(initResult);
    initResult = ztsClientNotificationSender.init(notificationManager, null, serverName);
    assertFalse(initResult);
    initResult = ztsClientNotificationSender.init(null, rolesProvider, serverName);
    assertFalse(initResult);
}
Also used : NotificationManager(com.yahoo.athenz.common.server.notification.NotificationManager) Authority(com.yahoo.athenz.auth.Authority) RolesProvider(com.yahoo.athenz.common.server.db.RolesProvider) Test(org.testng.annotations.Test)

Example 10 with NotificationManager

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

the class ZTSClientNotificationSenderImplTest method testSendNotificationInit.

@Test
public void testSendNotificationInit() {
    ZTSClientNotificationSenderImpl ztsClientNotificationSender = new ZTSClientNotificationSenderImpl();
    NotificationManager notificationManager = Mockito.mock(NotificationManager.class);
    RolesProvider rolesProvider = Mockito.mock(RolesProvider.class);
    String serverName = "testServer";
    ztsClientNotificationSender.init(notificationManager, rolesProvider, serverName);
    ZTSClientNotification ztsClientNotification = Mockito.mock(ZTSClientNotification.class);
    ztsClientNotificationSender.sendNotification(ztsClientNotification);
    Mockito.verify(notificationManager, Mockito.times(1)).sendNotifications(any());
}
Also used : ZTSClientNotification(com.yahoo.athenz.zts.ZTSClientNotification) NotificationManager(com.yahoo.athenz.common.server.notification.NotificationManager) RolesProvider(com.yahoo.athenz.common.server.db.RolesProvider) Test(org.testng.annotations.Test)

Aggregations

NotificationManager (com.yahoo.athenz.common.server.notification.NotificationManager)11 Test (org.testng.annotations.Test)9 RolesProvider (com.yahoo.athenz.common.server.db.RolesProvider)8 PoolableDataSource (com.yahoo.athenz.common.server.db.PoolableDataSource)2 NotificationToEmailConverterCommon (com.yahoo.athenz.common.server.notification.NotificationToEmailConverterCommon)2 ZTSClientNotification (com.yahoo.athenz.zts.ZTSClientNotification)2 ZTSClientNotificationSenderImpl (com.yahoo.athenz.zts.notification.ZTSClientNotificationSenderImpl)2 Authority (com.yahoo.athenz.auth.Authority)1 ZMSNotificationTaskFactory (com.yahoo.athenz.zms.notification.ZMSNotificationTaskFactory)1 ZTSNotificationTaskFactory (com.yahoo.athenz.zts.notification.ZTSNotificationTaskFactory)1 File (java.io.File)1