Search in sources :

Example 1 with NotificationManager

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

the class ZTSImpl method setNotificationManager.

private void setNotificationManager() {
    ZTSNotificationTaskFactory ztsNotificationTaskFactory = new ZTSNotificationTaskFactory(instanceCertManager, dataStore, hostnameResolver, userDomainPrefix, serverHostName, httpsPort, new NotificationToEmailConverterCommon(userAuthority));
    notificationManager = new NotificationManager(ztsNotificationTaskFactory.getNotificationTasks(), userAuthority);
    // Enable notifications for instanceCertManager
    instanceCertManager.enableCertStoreNotifications(notificationManager, dataStore, serverHostName);
    instanceCertManager.enableSSHStoreNotifications(notificationManager, dataStore, serverHostName);
}
Also used : NotificationToEmailConverterCommon(com.yahoo.athenz.common.server.notification.NotificationToEmailConverterCommon) NotificationManager(com.yahoo.athenz.common.server.notification.NotificationManager) ZTSNotificationTaskFactory(com.yahoo.athenz.zts.notification.ZTSNotificationTaskFactory)

Example 2 with NotificationManager

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

the class JDBCCertRecordStoreTest method testEnableNotifications.

@Test
public void testEnableNotifications() {
    PoolableDataSource mockDataSrc = Mockito.mock(PoolableDataSource.class);
    JDBCCertRecordStore store = new JDBCCertRecordStore(mockDataSrc);
    boolean 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);
    // Not supported for FileCertStore even if all dependencies provided
    assertFalse(isEnabled);
}
Also used : NotificationManager(com.yahoo.athenz.common.server.notification.NotificationManager) PoolableDataSource(com.yahoo.athenz.common.server.db.PoolableDataSource) RolesProvider(com.yahoo.athenz.common.server.db.RolesProvider) Test(org.testng.annotations.Test)

Example 3 with NotificationManager

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

the class ZTSClientNotificationSenderImplTest method testSendNotificationNotInit.

@Test
public void testSendNotificationNotInit() {
    ZTSClientNotificationSenderImpl ztsClientNotificationSender = new ZTSClientNotificationSenderImpl();
    NotificationManager notificationManager = Mockito.mock(NotificationManager.class);
    ztsClientNotificationSender.init(notificationManager, null, null);
    ZTSClientNotification ztsClientNotification = Mockito.mock(ZTSClientNotification.class);
    ztsClientNotificationSender.sendNotification(ztsClientNotification);
    Mockito.verify(notificationManager, Mockito.times(0)).sendNotifications(any());
}
Also used : ZTSClientNotification(com.yahoo.athenz.zts.ZTSClientNotification) NotificationManager(com.yahoo.athenz.common.server.notification.NotificationManager) Test(org.testng.annotations.Test)

Example 4 with NotificationManager

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

the class InstanceCertManagerTest method testeEnableCertStoreNotifications.

@Test
public void testeEnableCertStoreNotifications() {
    InstanceCertManager instance = new InstanceCertManager(null, null, null, true, null);
    boolean isEnabled = instance.enableCertStoreNotifications(null, null, null);
    assertFalse(isEnabled);
    CertRecordStore certStore = Mockito.mock(CertRecordStore.class);
    when(certStore.enableNotifications(any(), any(), any())).thenReturn(true);
    instance.setCertStore(certStore);
    NotificationManager notificationManager = Mockito.mock(NotificationManager.class);
    RolesProvider rolesProvider = Mockito.mock(RolesProvider.class);
    isEnabled = instance.enableCertStoreNotifications(notificationManager, rolesProvider, "testServer");
    assertTrue(isEnabled);
}
Also used : NotificationManager(com.yahoo.athenz.common.server.notification.NotificationManager) RolesProvider(com.yahoo.athenz.common.server.db.RolesProvider) Test(org.testng.annotations.Test)

Example 5 with NotificationManager

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

the class FileCertRecordStoreTest method testEnableNotifications.

@Test
public void testEnableNotifications() {
    FileCertRecordStore store = new FileCertRecordStore(new File("/tmp"));
    boolean 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);
    // Not supported for FileCertStore even if all dependencies provided
    assertFalse(isEnabled);
}
Also used : NotificationManager(com.yahoo.athenz.common.server.notification.NotificationManager) File(java.io.File) 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