use of com.yahoo.athenz.zts.ZTSClientNotification in project athenz by yahoo.
the class AWSZTSHealthNotificationTaskTest method testGetNotifications.
@Test
public void testGetNotifications() {
System.setProperty(ZTSConsts.ZTS_PROP_NOTIFICATION_AWS_HEALTH_DOMAIN, "testDomain");
ZTSClientNotification clientNotification = new ZTSClientNotification("zts.url", "role", "AWS", 1592346376, false, "testDomain");
RoleMember roleMember1 = new RoleMember();
roleMember1.setMemberName("user.test1");
RoleMember roleMember2 = new RoleMember();
roleMember2.setMemberName("user.test2");
List<RoleMember> roleMembers = new ArrayList<>();
roleMembers.add(roleMember1);
roleMembers.add(roleMember2);
Role adminRole = new Role();
adminRole.setRoleMembers(roleMembers);
adminRole.setName("testDomain:role.admin");
List<Role> roles = new ArrayList<>();
roles.add(adminRole);
when(dataStore.getRolesByDomain(eq("testDomain"))).thenReturn(roles);
AWSZTSHealthNotificationTask awsztsHealthNotificationTask = new AWSZTSHealthNotificationTask(clientNotification, dataStore, userDomainPrefix, serverName, notificationToEmailConverterCommon);
List<Notification> notifications = awsztsHealthNotificationTask.getNotifications();
assertEquals(1, notifications.size());
assertTrue(notifications.get(0).getRecipients().contains("user.test1"));
assertTrue(notifications.get(0).getRecipients().contains("user.test2"));
Timestamp expiration = Timestamp.fromMillis(clientNotification.getExpiration() * 1000);
assertEquals("zts.url;testDomain;role;" + expiration + ";Fail to get token of type AWS. ", notifications.get(0).getDetails().get("awsZtsHealth"));
assertEquals("testServer", notifications.get(0).getDetails().get("affectedZts"));
System.clearProperty(ZTSConsts.ZTS_PROP_NOTIFICATION_AWS_HEALTH_DOMAIN);
}
use of com.yahoo.athenz.zts.ZTSClientNotification 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());
}
use of com.yahoo.athenz.zts.ZTSClientNotification 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());
}
Aggregations