1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-11-30 00:02:06 +01:00

Add another test for deletion of non-existent user-ids from key

This commit is contained in:
Paul Schaub 2021-11-12 16:52:32 +01:00
parent d036cf2593
commit 74609e0ef7

View file

@ -5,9 +5,11 @@
package org.pgpainless.key.util;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.security.InvalidAlgorithmParameterException;
import java.security.NoSuchAlgorithmException;
import java.util.NoSuchElementException;
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPPublicKeyRing;
@ -36,7 +38,8 @@ public class KeyRingUtilTest {
}
@Test
public void testDeleteUserIdFromPublicKeyRing() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException {
public void testDeleteUserIdFromPublicKeyRing()
throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException {
PGPSecretKeyRing secretKeys = PGPainless.generateKeyRing()
.modernKeyRing("Alice", null);
@ -50,4 +53,14 @@ public class KeyRingUtilTest {
assertEquals(1, CollectionUtils.iteratorToList(publicKeys.getPublicKey().getUserIDs()).size());
}
@Test
public void testDeleteNonexistentUserIdFromKeyRingThrows()
throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException {
PGPSecretKeyRing secretKeys = PGPainless.generateKeyRing()
.modernKeyRing("Alice", null);
assertThrows(NoSuchElementException.class,
() -> KeyRingUtils.deleteUserIdFromSecretKeyRing(secretKeys, "Charlie"));
}
}