@Test
public void testValidateImpersonatorByGroupWhitelist() {

    // Wildcard
    ProxyUserValidation.validateImpersonator(OOZIE, ALICE);
    ProxyUserValidation.validateImpersonator(OOZIE, BOB);
    ProxyUserValidation.validateImpersonator(OOZIE, CHARLIE);
    // Specific group that only Alice is member of
    ProxyUserValidation.validateImpersonator(HIVE, ALICE);
    String[] someUsers = {BOB, CHARLIE};
    for (String user : someUsers) {
        try {
            ProxyUserValidation.validateImpersonator(HIVE, user);
            fail();
        } catch (StatusRuntimeException e) {
            assertEquals(Status.PERMISSION_DENIED.getCode(), e.getStatus().getCode());
            assertEquals("Impersonation disallowed for `hive/testhost@EXAMPLE.COM`", e.getStatus().getDescription());
        }
    }
    // Specific group that no one is member of
    String[] allUsers = {ALICE, BOB, CHARLIE};
    for (String user : allUsers) {
        try {
            ProxyUserValidation.validateImpersonator(SOLR, user);
            fail();
        } catch (StatusRuntimeException e) {
            assertEquals(Status.PERMISSION_DENIED.getCode(), e.getStatus().getCode());
            assertEquals("Impersonation disallowed for `solr/testhost@EXAMPLE.COM`", e.getStatus().getDescription());
        }
    }
}