@Test
public void readNoSecretFailWithTypeSymmetric() throws Exception {

  String keyValue = "01234567890123456";
  Keyset keyset =
      TestUtil.createKeyset(
          TestUtil.createKey(
              TestUtil.createHmacKeyData(keyValue.getBytes("UTF-8"), 16),
              42,
              KeyStatusType.ENABLED,
              OutputPrefixType.TINK));
  try {
    KeysetHandle unused = KeysetHandle.readNoSecret(keyset.toByteArray());
    fail("Expected GeneralSecurityException");
  } catch (GeneralSecurityException e) {
    assertExceptionContains(e, "keyset contains key material of type");
    assertExceptionContains(e, " type.googleapis.com/google.crypto.tink.HmacKey");
  }
  try {
    KeysetHandle unused =
        KeysetHandle.readNoSecret(BinaryKeysetReader.withBytes(keyset.toByteArray()));
    fail("Expected GeneralSecurityException");
  } catch (GeneralSecurityException e) {
    assertExceptionContains(e, "keyset contains key material");
  }
}