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);
}
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);
}
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));
}
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);
}
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);
}
Aggregations