@Test
public void testShouldFailIfTrustedKeyIsExpiredInECV2() throws Exception {

  JSONObject trustedKeysJson = new JSONObject(GOOGLE_VERIFYING_PUBLIC_KEYS_JSON);
  trustedKeysJson
      .getJSONArray("keys")
      .getJSONObject(INDEX_OF_GOOGLE_SIGNING_EC_V2)
      .put(
          "keyExpiration",
          // One day in the past
          String.valueOf(Instant.now().minus(Duration.standardDays(1)).getMillis()));
  PaymentMethodTokenRecipient recipient =
      new PaymentMethodTokenRecipient.Builder()
          .protocolVersion(PaymentMethodTokenConstants.PROTOCOL_VERSION_EC_V2)
          .senderVerifyingKeys(trustedKeysJson.toString())
          .recipientId(RECIPIENT_ID)
          .addRecipientPrivateKey(MERCHANT_PRIVATE_KEY_PKCS8_BASE64)
          .build();
  try {
    recipient.unseal(sealECV2(PLAINTEXT));
    fail("Expected GeneralSecurityException");
  } catch (GeneralSecurityException e) {
    assertEquals("no trusted keys are available for this protocol version", e.getMessage());
  }
}