1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-09-21 07:19:32 +02:00

Replace use of addPassphrase()/addDecryptionPassphrase() in tests with addMessagePassphrase()

This commit is contained in:
Paul Schaub 2024-08-22 13:42:30 +02:00
parent 69a57ef3bc
commit 67457bbe78
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
9 changed files with 17 additions and 17 deletions

View file

@ -153,6 +153,6 @@ public class DecryptAndVerifyMessageTest {
() -> PGPainless.decryptAndOrVerify()
.onInputStream(ciphertextIn)
.withOptions(ConsumerOptions.get()
.addDecryptionPassphrase(Passphrase.fromPassword("sw0rdf1sh"))));
.addMessagePassphrase(Passphrase.fromPassword("sw0rdf1sh"))));
}
}

View file

@ -282,7 +282,7 @@ public class OpenPgpMessageInputStreamTest {
EncryptionStream enc = PGPainless.encryptAndOrSign()
.onOutputStream(System.out)
.withOptions(ProducerOptions.encrypt(EncryptionOptions.get()
.addPassphrase(Passphrase.fromPassword(PASSPHRASE)))
.addMessagePassphrase(Passphrase.fromPassword(PASSPHRASE)))
.overrideCompressionAlgorithm(CompressionAlgorithm.UNCOMPRESSED));
enc.write(PLAINTEXT.getBytes(StandardCharsets.UTF_8));
enc.close();
@ -409,7 +409,7 @@ public class OpenPgpMessageInputStreamTest {
public void testProcessSENC_LIT(Processor processor)
throws PGPException, IOException {
Tuple<String, MessageMetadata> result = processor.process(SENC_LIT, ConsumerOptions.get()
.addDecryptionPassphrase(Passphrase.fromPassword(PASSPHRASE)));
.addMessagePassphrase(Passphrase.fromPassword(PASSPHRASE)));
String plain = result.getA();
assertEquals(PLAINTEXT, plain);
MessageMetadata metadata = result.getB();
@ -656,7 +656,7 @@ public class OpenPgpMessageInputStreamTest {
@Test
public void readAfterCloseTest() throws PGPException, IOException {
OpenPgpMessageInputStream pgpIn = get(SENC_LIT, ConsumerOptions.get()
.addDecryptionPassphrase(Passphrase.fromPassword(PASSPHRASE)));
.addMessagePassphrase(Passphrase.fromPassword(PASSPHRASE)));
Streams.drain(pgpIn); // read all
byte[] buf = new byte[1024];

View file

@ -193,7 +193,7 @@ public class PostponeDecryptionUsingKeyWithMissingPassphraseTest {
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify()
.onInputStream(new ByteArrayInputStream(ENCRYPTED_FOR_K2_PASS_K1.getBytes(StandardCharsets.UTF_8)))
.withOptions(new ConsumerOptions()
.addDecryptionPassphrase(PASSPHRASE)
.addMessagePassphrase(PASSPHRASE)
.addDecryptionKey(k1, protector)
.addDecryptionKey(k2, protector));

View file

@ -131,7 +131,7 @@ public class EncryptionOptionsTest {
public void testAddEmptyPassphraseFails() {
EncryptionOptions options = new EncryptionOptions();
assertThrows(IllegalArgumentException.class, () ->
options.addPassphrase(Passphrase.emptyPassphrase()));
options.addMessagePassphrase(Passphrase.emptyPassphrase()));
}
@Test

View file

@ -26,7 +26,7 @@ public class EncryptionStreamClosedTest {
EncryptionStream stream = PGPainless.encryptAndOrSign()
.onOutputStream(out)
.withOptions(ProducerOptions.encrypt(EncryptionOptions.encryptCommunications()
.addPassphrase(Passphrase.fromPassword("dummy"))));
.addMessagePassphrase(Passphrase.fromPassword("dummy"))));
// No close() called => getResult throws
assertThrows(IllegalStateException.class, stream::getResult);

View file

@ -23,7 +23,7 @@ public class HideArmorHeadersTest {
.onOutputStream(out)
.withOptions(ProducerOptions.encrypt(
EncryptionOptions.get()
.addPassphrase(Passphrase.fromPassword("sw0rdf1sh")))
.addMessagePassphrase(Passphrase.fromPassword("sw0rdf1sh")))
.setHideArmorHeaders(true));
encryptionStream.write("Hello, World!\n".getBytes());

View file

@ -195,7 +195,7 @@ public class Encrypt {
.onOutputStream(ciphertext)
.withOptions(ProducerOptions
.encrypt(EncryptionOptions.encryptCommunications()
.addPassphrase(Passphrase.fromPassword("p4ssphr4s3"))
.addMessagePassphrase(Passphrase.fromPassword("p4ssphr4s3"))
).setAsciiArmor(true)
);
@ -207,7 +207,7 @@ public class Encrypt {
// Decrypt
DecryptionStream decryptor = PGPainless.decryptAndOrVerify()
.onInputStream(new ByteArrayInputStream(asciiCiphertext.getBytes(StandardCharsets.UTF_8)))
.withOptions(new ConsumerOptions().addDecryptionPassphrase(Passphrase.fromPassword("p4ssphr4s3")));
.withOptions(new ConsumerOptions().addMessagePassphrase(Passphrase.fromPassword("p4ssphr4s3")));
ByteArrayOutputStream plaintext = new ByteArrayOutputStream();
Streams.pipeAll(decryptor, plaintext);

View file

@ -35,8 +35,8 @@ public class MultiPassphraseSymmetricEncryptionTest {
.onOutputStream(ciphertextOut)
.withOptions(ProducerOptions.encrypt(
EncryptionOptions.encryptCommunications()
.addPassphrase(Passphrase.fromPassword("p1"))
.addPassphrase(Passphrase.fromPassword("p2"))
.addMessagePassphrase(Passphrase.fromPassword("p1"))
.addMessagePassphrase(Passphrase.fromPassword("p2"))
).setAsciiArmor(false));
Streams.pipeAll(plaintextIn, encryptor);
@ -49,7 +49,7 @@ public class MultiPassphraseSymmetricEncryptionTest {
DecryptionStream decryptor = PGPainless.decryptAndOrVerify()
.onInputStream(new ByteArrayInputStream(ciphertext))
.withOptions(new ConsumerOptions()
.addDecryptionPassphrase(passphrase));
.addMessagePassphrase(passphrase));
ByteArrayOutputStream plaintextOut = new ByteArrayOutputStream();

View file

@ -53,7 +53,7 @@ public class SymmetricEncryptionTest {
.onOutputStream(ciphertextOut)
.withOptions(ProducerOptions.encrypt(
EncryptionOptions.encryptCommunications()
.addPassphrase(encryptionPassphrase)
.addMessagePassphrase(encryptionPassphrase)
.addRecipient(encryptionKey)
));
@ -66,7 +66,7 @@ public class SymmetricEncryptionTest {
DecryptionStream decryptor = PGPainless.decryptAndOrVerify()
.onInputStream(new ByteArrayInputStream(ciphertext))
.withOptions(new ConsumerOptions()
.addDecryptionPassphrase(encryptionPassphrase));
.addMessagePassphrase(encryptionPassphrase));
ByteArrayOutputStream decrypted = new ByteArrayOutputStream();
@ -103,7 +103,7 @@ public class SymmetricEncryptionTest {
EncryptionStream encryptor = PGPainless.encryptAndOrSign().onOutputStream(ciphertextOut)
.withOptions(ProducerOptions.encrypt(
EncryptionOptions.encryptCommunications()
.addPassphrase(Passphrase.fromPassword("mellon"))));
.addMessagePassphrase(Passphrase.fromPassword("mellon"))));
Streams.pipeAll(new ByteArrayInputStream(bytes), encryptor);
encryptor.close();
@ -112,6 +112,6 @@ public class SymmetricEncryptionTest {
.onInputStream(new ByteArrayInputStream(ciphertextOut.toByteArray()))
.withOptions(new ConsumerOptions()
.setMissingKeyPassphraseStrategy(MissingKeyPassphraseStrategy.THROW_EXCEPTION)
.addDecryptionPassphrase(Passphrase.fromPassword("meldir"))));
.addMessagePassphrase(Passphrase.fromPassword("meldir"))));
}
}