@Test
public void testValidateKeyset_multiplePrimaryKeys_shouldFail() throws Exception {

  String keyValue = "01234567890123456";
  // Multiple primary keys.
  Keyset invalidKeyset =
      TestUtil.createKeyset(
          TestUtil.createKey(
              TestUtil.createHmacKeyData(keyValue.getBytes("UTF-8"), 16),
              42,
              KeyStatusType.ENABLED,
              OutputPrefixType.TINK),
          TestUtil.createKey(
              TestUtil.createHmacKeyData(keyValue.getBytes("UTF-8"), 16),
              42,
              KeyStatusType.ENABLED,
              OutputPrefixType.TINK));
  try {
    Util.validateKeyset(invalidKeyset);
    fail("Invalid keyset. Expect GeneralSecurityException");
  } catch (GeneralSecurityException e) {
    assertExceptionContains(e, "keyset contains multiple primary keys");
  }
}