diff --git a/pgpainless-core/src/test/java/org/pgpainless/encryption_signing/EncryptionOptionsTest.java b/pgpainless-core/src/test/java/org/pgpainless/encryption_signing/EncryptionOptionsTest.java index 0da86b0c..84489473 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/encryption_signing/EncryptionOptionsTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/encryption_signing/EncryptionOptionsTest.java @@ -39,6 +39,7 @@ import org.junit.jupiter.api.Test; import org.pgpainless.PGPainless; import org.pgpainless.algorithm.KeyFlag; import org.pgpainless.algorithm.SymmetricKeyAlgorithm; +import org.pgpainless.exception.KeyValidationException; import org.pgpainless.key.SubkeyIdentifier; import org.pgpainless.key.generation.KeySpec; import org.pgpainless.key.generation.type.KeyType; @@ -181,4 +182,18 @@ public class EncryptionOptionsTest { options.addRecipients(collection); assertEquals(2, options.getEncryptionKeyIdentifiers().size()); } + + @Test + public void testAddRecipient_withValidUserId() { + EncryptionOptions options = new EncryptionOptions(); + options.addRecipient(publicKeys, "test@pgpainless.org"); + + assertEquals(1, options.getEncryptionMethods().size()); + } + + @Test + public void testAddRecipient_withInvalidUserId() { + EncryptionOptions options = new EncryptionOptions(); + assertThrows(KeyValidationException.class, () -> options.addRecipient(publicKeys, "invalid@user.id")); + } }