mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-22 20:32:05 +01:00
Replace use of addPassphrase()/addDecryptionPassphrase() in tests with addMessagePassphrase()
This commit is contained in:
parent
69a57ef3bc
commit
67457bbe78
9 changed files with 17 additions and 17 deletions
|
@ -153,6 +153,6 @@ public class DecryptAndVerifyMessageTest {
|
||||||
() -> PGPainless.decryptAndOrVerify()
|
() -> PGPainless.decryptAndOrVerify()
|
||||||
.onInputStream(ciphertextIn)
|
.onInputStream(ciphertextIn)
|
||||||
.withOptions(ConsumerOptions.get()
|
.withOptions(ConsumerOptions.get()
|
||||||
.addDecryptionPassphrase(Passphrase.fromPassword("sw0rdf1sh"))));
|
.addMessagePassphrase(Passphrase.fromPassword("sw0rdf1sh"))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -282,7 +282,7 @@ public class OpenPgpMessageInputStreamTest {
|
||||||
EncryptionStream enc = PGPainless.encryptAndOrSign()
|
EncryptionStream enc = PGPainless.encryptAndOrSign()
|
||||||
.onOutputStream(System.out)
|
.onOutputStream(System.out)
|
||||||
.withOptions(ProducerOptions.encrypt(EncryptionOptions.get()
|
.withOptions(ProducerOptions.encrypt(EncryptionOptions.get()
|
||||||
.addPassphrase(Passphrase.fromPassword(PASSPHRASE)))
|
.addMessagePassphrase(Passphrase.fromPassword(PASSPHRASE)))
|
||||||
.overrideCompressionAlgorithm(CompressionAlgorithm.UNCOMPRESSED));
|
.overrideCompressionAlgorithm(CompressionAlgorithm.UNCOMPRESSED));
|
||||||
enc.write(PLAINTEXT.getBytes(StandardCharsets.UTF_8));
|
enc.write(PLAINTEXT.getBytes(StandardCharsets.UTF_8));
|
||||||
enc.close();
|
enc.close();
|
||||||
|
@ -409,7 +409,7 @@ public class OpenPgpMessageInputStreamTest {
|
||||||
public void testProcessSENC_LIT(Processor processor)
|
public void testProcessSENC_LIT(Processor processor)
|
||||||
throws PGPException, IOException {
|
throws PGPException, IOException {
|
||||||
Tuple<String, MessageMetadata> result = processor.process(SENC_LIT, ConsumerOptions.get()
|
Tuple<String, MessageMetadata> result = processor.process(SENC_LIT, ConsumerOptions.get()
|
||||||
.addDecryptionPassphrase(Passphrase.fromPassword(PASSPHRASE)));
|
.addMessagePassphrase(Passphrase.fromPassword(PASSPHRASE)));
|
||||||
String plain = result.getA();
|
String plain = result.getA();
|
||||||
assertEquals(PLAINTEXT, plain);
|
assertEquals(PLAINTEXT, plain);
|
||||||
MessageMetadata metadata = result.getB();
|
MessageMetadata metadata = result.getB();
|
||||||
|
@ -656,7 +656,7 @@ public class OpenPgpMessageInputStreamTest {
|
||||||
@Test
|
@Test
|
||||||
public void readAfterCloseTest() throws PGPException, IOException {
|
public void readAfterCloseTest() throws PGPException, IOException {
|
||||||
OpenPgpMessageInputStream pgpIn = get(SENC_LIT, ConsumerOptions.get()
|
OpenPgpMessageInputStream pgpIn = get(SENC_LIT, ConsumerOptions.get()
|
||||||
.addDecryptionPassphrase(Passphrase.fromPassword(PASSPHRASE)));
|
.addMessagePassphrase(Passphrase.fromPassword(PASSPHRASE)));
|
||||||
Streams.drain(pgpIn); // read all
|
Streams.drain(pgpIn); // read all
|
||||||
|
|
||||||
byte[] buf = new byte[1024];
|
byte[] buf = new byte[1024];
|
||||||
|
|
|
@ -193,7 +193,7 @@ public class PostponeDecryptionUsingKeyWithMissingPassphraseTest {
|
||||||
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify()
|
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify()
|
||||||
.onInputStream(new ByteArrayInputStream(ENCRYPTED_FOR_K2_PASS_K1.getBytes(StandardCharsets.UTF_8)))
|
.onInputStream(new ByteArrayInputStream(ENCRYPTED_FOR_K2_PASS_K1.getBytes(StandardCharsets.UTF_8)))
|
||||||
.withOptions(new ConsumerOptions()
|
.withOptions(new ConsumerOptions()
|
||||||
.addDecryptionPassphrase(PASSPHRASE)
|
.addMessagePassphrase(PASSPHRASE)
|
||||||
.addDecryptionKey(k1, protector)
|
.addDecryptionKey(k1, protector)
|
||||||
.addDecryptionKey(k2, protector));
|
.addDecryptionKey(k2, protector));
|
||||||
|
|
||||||
|
|
|
@ -131,7 +131,7 @@ public class EncryptionOptionsTest {
|
||||||
public void testAddEmptyPassphraseFails() {
|
public void testAddEmptyPassphraseFails() {
|
||||||
EncryptionOptions options = new EncryptionOptions();
|
EncryptionOptions options = new EncryptionOptions();
|
||||||
assertThrows(IllegalArgumentException.class, () ->
|
assertThrows(IllegalArgumentException.class, () ->
|
||||||
options.addPassphrase(Passphrase.emptyPassphrase()));
|
options.addMessagePassphrase(Passphrase.emptyPassphrase()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class EncryptionStreamClosedTest {
|
||||||
EncryptionStream stream = PGPainless.encryptAndOrSign()
|
EncryptionStream stream = PGPainless.encryptAndOrSign()
|
||||||
.onOutputStream(out)
|
.onOutputStream(out)
|
||||||
.withOptions(ProducerOptions.encrypt(EncryptionOptions.encryptCommunications()
|
.withOptions(ProducerOptions.encrypt(EncryptionOptions.encryptCommunications()
|
||||||
.addPassphrase(Passphrase.fromPassword("dummy"))));
|
.addMessagePassphrase(Passphrase.fromPassword("dummy"))));
|
||||||
|
|
||||||
// No close() called => getResult throws
|
// No close() called => getResult throws
|
||||||
assertThrows(IllegalStateException.class, stream::getResult);
|
assertThrows(IllegalStateException.class, stream::getResult);
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class HideArmorHeadersTest {
|
||||||
.onOutputStream(out)
|
.onOutputStream(out)
|
||||||
.withOptions(ProducerOptions.encrypt(
|
.withOptions(ProducerOptions.encrypt(
|
||||||
EncryptionOptions.get()
|
EncryptionOptions.get()
|
||||||
.addPassphrase(Passphrase.fromPassword("sw0rdf1sh")))
|
.addMessagePassphrase(Passphrase.fromPassword("sw0rdf1sh")))
|
||||||
.setHideArmorHeaders(true));
|
.setHideArmorHeaders(true));
|
||||||
|
|
||||||
encryptionStream.write("Hello, World!\n".getBytes());
|
encryptionStream.write("Hello, World!\n".getBytes());
|
||||||
|
|
|
@ -195,7 +195,7 @@ public class Encrypt {
|
||||||
.onOutputStream(ciphertext)
|
.onOutputStream(ciphertext)
|
||||||
.withOptions(ProducerOptions
|
.withOptions(ProducerOptions
|
||||||
.encrypt(EncryptionOptions.encryptCommunications()
|
.encrypt(EncryptionOptions.encryptCommunications()
|
||||||
.addPassphrase(Passphrase.fromPassword("p4ssphr4s3"))
|
.addMessagePassphrase(Passphrase.fromPassword("p4ssphr4s3"))
|
||||||
).setAsciiArmor(true)
|
).setAsciiArmor(true)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@ public class Encrypt {
|
||||||
// Decrypt
|
// Decrypt
|
||||||
DecryptionStream decryptor = PGPainless.decryptAndOrVerify()
|
DecryptionStream decryptor = PGPainless.decryptAndOrVerify()
|
||||||
.onInputStream(new ByteArrayInputStream(asciiCiphertext.getBytes(StandardCharsets.UTF_8)))
|
.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();
|
ByteArrayOutputStream plaintext = new ByteArrayOutputStream();
|
||||||
Streams.pipeAll(decryptor, plaintext);
|
Streams.pipeAll(decryptor, plaintext);
|
||||||
|
|
|
@ -35,8 +35,8 @@ public class MultiPassphraseSymmetricEncryptionTest {
|
||||||
.onOutputStream(ciphertextOut)
|
.onOutputStream(ciphertextOut)
|
||||||
.withOptions(ProducerOptions.encrypt(
|
.withOptions(ProducerOptions.encrypt(
|
||||||
EncryptionOptions.encryptCommunications()
|
EncryptionOptions.encryptCommunications()
|
||||||
.addPassphrase(Passphrase.fromPassword("p1"))
|
.addMessagePassphrase(Passphrase.fromPassword("p1"))
|
||||||
.addPassphrase(Passphrase.fromPassword("p2"))
|
.addMessagePassphrase(Passphrase.fromPassword("p2"))
|
||||||
).setAsciiArmor(false));
|
).setAsciiArmor(false));
|
||||||
|
|
||||||
Streams.pipeAll(plaintextIn, encryptor);
|
Streams.pipeAll(plaintextIn, encryptor);
|
||||||
|
@ -49,7 +49,7 @@ public class MultiPassphraseSymmetricEncryptionTest {
|
||||||
DecryptionStream decryptor = PGPainless.decryptAndOrVerify()
|
DecryptionStream decryptor = PGPainless.decryptAndOrVerify()
|
||||||
.onInputStream(new ByteArrayInputStream(ciphertext))
|
.onInputStream(new ByteArrayInputStream(ciphertext))
|
||||||
.withOptions(new ConsumerOptions()
|
.withOptions(new ConsumerOptions()
|
||||||
.addDecryptionPassphrase(passphrase));
|
.addMessagePassphrase(passphrase));
|
||||||
|
|
||||||
ByteArrayOutputStream plaintextOut = new ByteArrayOutputStream();
|
ByteArrayOutputStream plaintextOut = new ByteArrayOutputStream();
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class SymmetricEncryptionTest {
|
||||||
.onOutputStream(ciphertextOut)
|
.onOutputStream(ciphertextOut)
|
||||||
.withOptions(ProducerOptions.encrypt(
|
.withOptions(ProducerOptions.encrypt(
|
||||||
EncryptionOptions.encryptCommunications()
|
EncryptionOptions.encryptCommunications()
|
||||||
.addPassphrase(encryptionPassphrase)
|
.addMessagePassphrase(encryptionPassphrase)
|
||||||
.addRecipient(encryptionKey)
|
.addRecipient(encryptionKey)
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ public class SymmetricEncryptionTest {
|
||||||
DecryptionStream decryptor = PGPainless.decryptAndOrVerify()
|
DecryptionStream decryptor = PGPainless.decryptAndOrVerify()
|
||||||
.onInputStream(new ByteArrayInputStream(ciphertext))
|
.onInputStream(new ByteArrayInputStream(ciphertext))
|
||||||
.withOptions(new ConsumerOptions()
|
.withOptions(new ConsumerOptions()
|
||||||
.addDecryptionPassphrase(encryptionPassphrase));
|
.addMessagePassphrase(encryptionPassphrase));
|
||||||
|
|
||||||
ByteArrayOutputStream decrypted = new ByteArrayOutputStream();
|
ByteArrayOutputStream decrypted = new ByteArrayOutputStream();
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ public class SymmetricEncryptionTest {
|
||||||
EncryptionStream encryptor = PGPainless.encryptAndOrSign().onOutputStream(ciphertextOut)
|
EncryptionStream encryptor = PGPainless.encryptAndOrSign().onOutputStream(ciphertextOut)
|
||||||
.withOptions(ProducerOptions.encrypt(
|
.withOptions(ProducerOptions.encrypt(
|
||||||
EncryptionOptions.encryptCommunications()
|
EncryptionOptions.encryptCommunications()
|
||||||
.addPassphrase(Passphrase.fromPassword("mellon"))));
|
.addMessagePassphrase(Passphrase.fromPassword("mellon"))));
|
||||||
|
|
||||||
Streams.pipeAll(new ByteArrayInputStream(bytes), encryptor);
|
Streams.pipeAll(new ByteArrayInputStream(bytes), encryptor);
|
||||||
encryptor.close();
|
encryptor.close();
|
||||||
|
@ -112,6 +112,6 @@ public class SymmetricEncryptionTest {
|
||||||
.onInputStream(new ByteArrayInputStream(ciphertextOut.toByteArray()))
|
.onInputStream(new ByteArrayInputStream(ciphertextOut.toByteArray()))
|
||||||
.withOptions(new ConsumerOptions()
|
.withOptions(new ConsumerOptions()
|
||||||
.setMissingKeyPassphraseStrategy(MissingKeyPassphraseStrategy.THROW_EXCEPTION)
|
.setMissingKeyPassphraseStrategy(MissingKeyPassphraseStrategy.THROW_EXCEPTION)
|
||||||
.addDecryptionPassphrase(Passphrase.fromPassword("meldir"))));
|
.addMessagePassphrase(Passphrase.fromPassword("meldir"))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue