Search in sources :

Example 1 with DebugUserAuthority

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");
}
Also used : DebugUserAuthority(com.yahoo.athenz.common.server.debug.DebugUserAuthority) HashSet(java.util.HashSet) Test(org.testng.annotations.Test) NotificationAuthorityForTest(com.yahoo.athenz.common.server.notification.impl.NotificationAuthorityForTest)

Aggregations

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