@Test
public void validateKey_notValid_throws() throws Exception {

  JwtHmacKey validKey = factory.createKey(makeJwtHmacKeyFormat(32, HashType.SHA256));
  try {
    manager.validateKey(
        JwtHmacKey.newBuilder(validKey)
            .setKeyValue(ByteString.copyFrom(Random.randBytes(31)))
            .build());
    fail();
  } catch (GeneralSecurityException e) {
    // expected
  }
}