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

Even more EncryptionOptions tests

This commit is contained in:
Paul Schaub 2021-06-10 15:18:31 +02:00
parent 762d9d4803
commit 7696f120e6
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -39,6 +39,7 @@ import org.junit.jupiter.api.Test;
import org.pgpainless.PGPainless; import org.pgpainless.PGPainless;
import org.pgpainless.algorithm.KeyFlag; import org.pgpainless.algorithm.KeyFlag;
import org.pgpainless.algorithm.SymmetricKeyAlgorithm; import org.pgpainless.algorithm.SymmetricKeyAlgorithm;
import org.pgpainless.exception.KeyValidationException;
import org.pgpainless.key.SubkeyIdentifier; import org.pgpainless.key.SubkeyIdentifier;
import org.pgpainless.key.generation.KeySpec; import org.pgpainless.key.generation.KeySpec;
import org.pgpainless.key.generation.type.KeyType; import org.pgpainless.key.generation.type.KeyType;
@ -181,4 +182,18 @@ public class EncryptionOptionsTest {
options.addRecipients(collection); options.addRecipients(collection);
assertEquals(2, options.getEncryptionKeyIdentifiers().size()); 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"));
}
} }