@Test
public void testCheckAudience() {

  // Empty allowed list or audience.
  assertFalse(GoogleAuth.checkAudience(AUDIENCE1, ImmutableList.<String>of(), CLIENT_ID1));
  assertFalse(GoogleAuth.checkAudience(AUDIENCE1, null, CLIENT_ID1));
  assertFalse(GoogleAuth.checkAudience("", AUDIENCE_LIST, CLIENT_ID1));
  assertFalse(GoogleAuth.checkAudience(null, AUDIENCE_LIST, CLIENT_ID1));
  // In or not in whitelist.
  assertTrue(GoogleAuth.checkAudience(AUDIENCE1, AUDIENCE_LIST, CLIENT_ID1));
  assertFalse(GoogleAuth.checkAudience(AUDIENCE2, AUDIENCE_LIST, CLIENT_ID1));
  // Equals to client id.
  assertTrue(GoogleAuth.checkAudience(CLIENT_ID1, AUDIENCE_LIST, CLIENT_ID1));
}