@Test
public void testRegisterKeyManager_deprecated_LessRestrictedNewKeyAllowed_shouldThrowException()
    throws Exception {

  String typeUrl = "totallyDifferentTypeUrl";
  Registry.registerKeyManager(typeUrl, new CustomAeadKeyManager(typeUrl), false);
  try {
    Registry.registerKeyManager(typeUrl, new CustomAeadKeyManager(typeUrl), true);
    fail("Expected GeneralSecurityException");
  } catch (GeneralSecurityException e) {
    // expected
  }
}