@Test
public void testShouldFailIfVerifyingWithDifferentKey() throws Exception {

  JSONObject trustedKeysJson = new JSONObject(GOOGLE_VERIFYING_PUBLIC_KEYS_JSON);
  trustedKeysJson
      .getJSONArray("keys")
      .getJSONObject(0)
      .put("base64", ALTERNATE_PUBLIC_SIGNING_KEY);
  RewardedAdsVerifier verifier =
      new RewardedAdsVerifier.Builder()
          .setVerifyingPublicKeys(trustedKeysJson.toString())
          .build();
  try {
    verifier.verify(signUrl(REWARD_URL, GOOGLE_SIGNING_PRIVATE_KEY_PKCS8_BASE64, KEY_ID));
    fail("Expected GeneralSecurityException");
  } catch (GeneralSecurityException e) {
    assertEquals("Invalid signature", e.getMessage());
  }
}