Search in sources :

Example 1 with NotificationAuthorityForTest

use of com.yahoo.athenz.common.server.notification.impl.NotificationAuthorityForTest in project athenz by yahoo.

the class NotificationToEmailConverterCommonTest method testGetFullyQualifiedEmailAddressesUserAuthority.

@Test
public void testGetFullyQualifiedEmailAddressesUserAuthority() {
    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");
    Set<String> recipients = new HashSet<>(Arrays.asList("entuser.user1", "entuser.user2", "entuser.user3", "unknown.user"));
    Authority notificationAuthorityForTest = new NotificationAuthorityForTest();
    NotificationToEmailConverterCommon notificationToEmailConverterCommon = new NotificationToEmailConverterCommon(notificationAuthorityForTest);
    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");
}
Also used : Authority(com.yahoo.athenz.auth.Authority) DebugUserAuthority(com.yahoo.athenz.common.server.debug.DebugUserAuthority) NotificationAuthorityForTest(com.yahoo.athenz.common.server.notification.impl.NotificationAuthorityForTest) HashSet(java.util.HashSet) Test(org.testng.annotations.Test) NotificationAuthorityForTest(com.yahoo.athenz.common.server.notification.impl.NotificationAuthorityForTest)

Aggregations

Authority (com.yahoo.athenz.auth.Authority)1 DebugUserAuthority (com.yahoo.athenz.common.server.debug.DebugUserAuthority)1 NotificationAuthorityForTest (com.yahoo.athenz.common.server.notification.impl.NotificationAuthorityForTest)1 HashSet (java.util.HashSet)1 Test (org.testng.annotations.Test)1