use of com.yahoo.athenz.common.server.debug.DebugUserAuthority in project athenz by yahoo.
the class NotificationToEmailConverterCommonTest method testGetFullyQualifiedEmailAddressesUserAuthorityProp.
@Test
public void testGetFullyQualifiedEmailAddressesUserAuthorityProp() {
System.clearProperty("athenz.user_domain");
System.setProperty("athenz.user_domain", "entuser");
System.setProperty("athenz.notification_email_domain_from", "from.example.com");
System.setProperty("athenz.notification_email_domain_to", "example.com");
System.setProperty("athenz.notification_user_authority", "com.yahoo.athenz.common.server.notification.impl.NotificationAuthorityForTest");
Set<String> recipients = new HashSet<>(Arrays.asList("entuser.user1", "entuser.user2", "entuser.user3", "unknown.user"));
// Verify when athenz.notification_user_authority is set it will take precedence over passed authority
DebugUserAuthority debugUserAuthority = new DebugUserAuthority();
NotificationToEmailConverterCommon notificationToEmailConverterCommon = new NotificationToEmailConverterCommon(debugUserAuthority);
Set<String> recipientsResp = notificationToEmailConverterCommon.getFullyQualifiedEmailAddresses(recipients);
assertNotNull(recipientsResp);
assertEquals(recipientsResp.size(), 4);
assertTrue(recipientsResp.contains("entuser.user1@mail.from.authority.com"));
assertTrue(recipientsResp.contains("entuser.user2@mail.from.authority.com"));
assertTrue(recipientsResp.contains("entuser.user3@mail.from.authority.com"));
assertTrue(recipientsResp.contains("unknown.user@example.com"));
System.clearProperty("athenz.notification_email_domain_from");
System.clearProperty("athenz.notification_email_domain_to");
System.clearProperty("athenz.user_domain");
System.clearProperty("athenz.notification_user_authority");
}
Aggregations