Search in sources :

Example 6 with RolesProvider

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

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

Example 8 with RolesProvider

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

the class NotificationManagerTest method testPrintNotificationDetailsToLog.

@Test
public void testPrintNotificationDetailsToLog() {
    RolesProvider rolesProvider = Mockito.mock(RolesProvider.class);
    DomainRoleMembersFetcher domainRoleMembersFetcher = new DomainRoleMembersFetcher(rolesProvider, USER_DOMAIN_PREFIX);
    NotificationCommon notificationCommon = new NotificationCommon(domainRoleMembersFetcher, USER_DOMAIN_PREFIX);
    assertNull(notificationCommon.printNotificationDetailsToLog(null, "descrition", LOGGER));
    assertNotNull(notificationCommon.printNotificationDetailsToLog(new ArrayList<>(), "descrition", LOGGER));
    List<Notification> notifications = new ArrayList<>();
    Map<String, String> details = new HashMap<>();
    details.put("test", "test");
    notifications.add(new Notification().setDetails(details));
    assertNotNull(notificationCommon.printNotificationDetailsToLog(notifications, "descrition", LOGGER));
}
Also used : RolesProvider(com.yahoo.athenz.common.server.db.RolesProvider) Test(org.testng.annotations.Test)

Example 9 with RolesProvider

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

the class NotificationManagerTest method testNotificationManagerFail.

@Test
public void testNotificationManagerFail() {
    System.setProperty(NOTIFICATION_PROP_SERVICE_FACTORY_CLASS, "aa");
    RolesProvider rolesProvider = Mockito.mock(RolesProvider.class);
    NotificationManager notificationManager = getNotificationManager(null);
    assertNotNull(notificationManager);
    assertFalse(notificationManager.isNotificationFeatureAvailable());
    notificationManager.shutdown();
    System.clearProperty(NOTIFICATION_PROP_SERVICE_FACTORY_CLASS);
}
Also used : RolesProvider(com.yahoo.athenz.common.server.db.RolesProvider) Test(org.testng.annotations.Test)

Example 10 with RolesProvider

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

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