Search in sources :

Example 11 with RolesProvider

use of com.yahoo.athenz.common.server.db.RolesProvider 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 12 with RolesProvider

use of com.yahoo.athenz.common.server.db.RolesProvider 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 13 with RolesProvider

use of com.yahoo.athenz.common.server.db.RolesProvider 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)

Example 14 with RolesProvider

use of com.yahoo.athenz.common.server.db.RolesProvider in project athenz by yahoo.

the class JDBCSSHRecordStoreTest method testEnableNotifications.

@Test
public void testEnableNotifications() {
    PoolableDataSource mockDataSrc = Mockito.mock(PoolableDataSource.class);
    JDBCSSHRecordStore store = new JDBCSSHRecordStore(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)

Aggregations

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