mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-12-03 17:52:07 +01:00
Replace @MethodSource annotation with @ArgumentsSource
This commit is contained in:
parent
a66b45c3d2
commit
2ebf4be39c
35 changed files with 225 additions and 169 deletions
|
@ -20,14 +20,15 @@ import org.bouncycastle.openpgp.PGPLiteralDataGenerator;
|
|||
import org.bouncycastle.openpgp.PGPObjectFactory;
|
||||
import org.bouncycastle.util.io.Streams;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
import org.pgpainless.implementation.ImplementationFactory;
|
||||
import org.pgpainless.util.PGPUtilWrapper;
|
||||
import org.pgpainless.util.TestImplementationFactoryProvider;
|
||||
|
||||
public class PGPUtilWrapperTest {
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void testGetDecoderStream(ImplementationFactory implementationFactory) throws IOException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
|||
import org.bouncycastle.util.io.Streams;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.algorithm.CompressionAlgorithm;
|
||||
import org.pgpainless.algorithm.SymmetricKeyAlgorithm;
|
||||
|
@ -26,6 +26,7 @@ import org.pgpainless.implementation.ImplementationFactory;
|
|||
import org.pgpainless.key.SubkeyIdentifier;
|
||||
import org.pgpainless.key.TestKeys;
|
||||
import org.pgpainless.key.util.KeyRingUtils;
|
||||
import org.pgpainless.util.TestImplementationFactoryProvider;
|
||||
|
||||
public class DecryptAndVerifyMessageTest {
|
||||
|
||||
|
@ -42,7 +43,7 @@ public class DecryptAndVerifyMessageTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void decryptMessageAndVerifySignatureTest(ImplementationFactory implementationFactory) throws Exception {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
String encryptedMessage = TestKeys.MSG_SIGN_CRYPT_JULIET_JULIET;
|
||||
|
|
|
@ -17,17 +17,18 @@ import org.bouncycastle.openpgp.PGPPublicKey;
|
|||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.bouncycastle.util.io.Streams;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.algorithm.EncryptionPurpose;
|
||||
import org.pgpainless.implementation.ImplementationFactory;
|
||||
import org.pgpainless.key.SubkeyIdentifier;
|
||||
import org.pgpainless.key.info.KeyRingInfo;
|
||||
import org.pgpainless.util.TestImplementationFactoryProvider;
|
||||
|
||||
public class DecryptHiddenRecipientMessage {
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void testDecryptionWithWildcardRecipient(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
String secretKeyAscii = "-----BEGIN PGP PRIVATE KEY BLOCK-----\n" +
|
||||
|
|
|
@ -18,15 +18,15 @@ import org.bouncycastle.openpgp.PGPException;
|
|||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.bouncycastle.openpgp.PGPSecretKeyRingCollection;
|
||||
import org.bouncycastle.util.io.Streams;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.exception.MessageNotIntegrityProtectedException;
|
||||
import org.pgpainless.exception.ModificationDetectionException;
|
||||
import org.pgpainless.implementation.ImplementationFactory;
|
||||
import org.pgpainless.key.protection.SecretKeyRingProtector;
|
||||
import org.pgpainless.util.Passphrase;
|
||||
import org.pgpainless.util.TestImplementationFactoryProvider;
|
||||
|
||||
public class ModificationDetectionTests {
|
||||
|
||||
|
@ -210,7 +210,7 @@ public class ModificationDetectionTests {
|
|||
* @throws PGPException in case of a pgp error
|
||||
*/
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void testMissingMDCThrowsByDefault(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -231,7 +231,7 @@ public class ModificationDetectionTests {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void testTamperedCiphertextThrows(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(MESSAGE_TAMPERED_CIPHERTEXT.getBytes(StandardCharsets.UTF_8));
|
||||
|
@ -247,7 +247,7 @@ public class ModificationDetectionTests {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void testIgnoreTamperedCiphertext(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(MESSAGE_TAMPERED_CIPHERTEXT.getBytes(StandardCharsets.UTF_8));
|
||||
|
@ -264,7 +264,7 @@ public class ModificationDetectionTests {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void testTamperedMDCThrowsByDefault(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(MESSAGE_TAMPERED_MDC.getBytes(StandardCharsets.UTF_8));
|
||||
|
@ -280,7 +280,7 @@ public class ModificationDetectionTests {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void testIgnoreTamperedMDC(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(MESSAGE_TAMPERED_MDC.getBytes(StandardCharsets.UTF_8));
|
||||
|
@ -296,7 +296,7 @@ public class ModificationDetectionTests {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void testTruncatedMDCThrows(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(MESSAGE_TRUNCATED_MDC.getBytes(StandardCharsets.UTF_8));
|
||||
|
@ -311,7 +311,7 @@ public class ModificationDetectionTests {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void testMDCWithBadCTBThrows(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(MESSAGE_MDC_WITH_BAD_CTB.getBytes(StandardCharsets.UTF_8));
|
||||
|
@ -327,7 +327,7 @@ public class ModificationDetectionTests {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void testIgnoreMDCWithBadCTB(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(MESSAGE_MDC_WITH_BAD_CTB.getBytes(StandardCharsets.UTF_8));
|
||||
|
@ -344,7 +344,7 @@ public class ModificationDetectionTests {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void testMDCWithBadLengthThrows(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(MESSAGE_MDC_WITH_BAD_LENGTH.getBytes(StandardCharsets.UTF_8));
|
||||
|
@ -360,7 +360,7 @@ public class ModificationDetectionTests {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void testIgnoreMDCWithBadLength(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(MESSAGE_MDC_WITH_BAD_LENGTH.getBytes(StandardCharsets.UTF_8));
|
||||
|
@ -376,8 +376,10 @@ public class ModificationDetectionTests {
|
|||
decryptionStream.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decryptMessageWithSEDPacket() throws IOException, PGPException {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void decryptMessageWithSEDPacket(ImplementationFactory implementationFactory) throws IOException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
Passphrase passphrase = Passphrase.fromPassword("flowcrypt compatibility tests");
|
||||
String key = "-----BEGIN PGP PRIVATE KEY BLOCK-----\r\n" +
|
||||
"Version: FlowCrypt 6.9.1 Gmail Encryption\r\n" +
|
||||
|
|
|
@ -15,9 +15,10 @@ import org.bouncycastle.openpgp.PGPException;
|
|||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.bouncycastle.util.io.Streams;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.implementation.ImplementationFactory;
|
||||
import org.pgpainless.util.TestImplementationFactoryProvider;
|
||||
|
||||
public class RecursionDepthTest {
|
||||
|
||||
|
@ -27,8 +28,9 @@ public class RecursionDepthTest {
|
|||
* @see <a href="https://tests.sequoia-pgp.org/#Maximum_recursion_depth">Sequoia-PGP Test Suite</a>
|
||||
*/
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
public void decryptionAbortsWhenMaximumRecursionDepthReachedTest(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void decryptionAbortsWhenMaximumRecursionDepthReachedTest(ImplementationFactory implementationFactory)
|
||||
throws IOException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
String key = "-----BEGIN PGP PRIVATE KEY BLOCK-----\n" +
|
||||
"Comment: Bob's OpenPGP Transferable Secret Key\n" +
|
||||
|
|
|
@ -25,9 +25,8 @@ import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
|||
import org.bouncycastle.openpgp.PGPSignature;
|
||||
import org.bouncycastle.util.io.Streams;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.algorithm.DocumentSignatureType;
|
||||
import org.pgpainless.algorithm.KeyFlag;
|
||||
|
@ -48,6 +47,7 @@ import org.pgpainless.key.protection.UnprotectedKeysProtector;
|
|||
import org.pgpainless.key.util.KeyRingUtils;
|
||||
import org.pgpainless.policy.Policy;
|
||||
import org.pgpainless.util.ArmoredOutputStreamFactory;
|
||||
import org.pgpainless.util.TestImplementationFactoryProvider;
|
||||
|
||||
public class EncryptDecryptTest {
|
||||
|
||||
|
@ -71,7 +71,7 @@ public class EncryptDecryptTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void freshKeysRsaToElGamalTest(ImplementationFactory implementationFactory)
|
||||
throws PGPException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, IOException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
@ -89,7 +89,7 @@ public class EncryptDecryptTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void freshKeysRsaToRsaTest(ImplementationFactory implementationFactory)
|
||||
throws PGPException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, IOException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
@ -100,7 +100,7 @@ public class EncryptDecryptTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void freshKeysEcToEcTest(ImplementationFactory implementationFactory)
|
||||
throws IOException, PGPException, NoSuchAlgorithmException, InvalidAlgorithmParameterException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
@ -111,7 +111,7 @@ public class EncryptDecryptTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void freshKeysEcToRsaTest(ImplementationFactory implementationFactory)
|
||||
throws PGPException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, IOException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
@ -122,7 +122,7 @@ public class EncryptDecryptTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void freshKeysRsaToEcTest(ImplementationFactory implementationFactory)
|
||||
throws PGPException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, IOException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
@ -133,7 +133,7 @@ public class EncryptDecryptTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void existingRsaKeysTest(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
PGPSecretKeyRing sender = TestKeys.getJulietSecretKeyRing();
|
||||
|
@ -198,7 +198,7 @@ public class EncryptDecryptTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void testDetachedSignatureCreationAndVerification(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -244,7 +244,7 @@ public class EncryptDecryptTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void testOnePassSignatureCreationAndVerification(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
PGPSecretKeyRing signingKeys = TestKeys.getJulietSecretKeyRing();
|
||||
|
@ -274,8 +274,10 @@ public class EncryptDecryptTest {
|
|||
assertFalse(metadata.getVerifiedSignatures().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void expiredSubkeyBacksigTest() throws IOException {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void expiredSubkeyBacksigTest(ImplementationFactory implementationFactory) throws IOException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
String key = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" +
|
||||
"\n" +
|
||||
"xsDNBF2lnPIBDAC5cL9PQoQLTMuhjbYvb4Ncuuo0bfmgPRFywX53jPhoFf4Zg6mv\n" +
|
||||
|
|
|
@ -12,15 +12,16 @@ import java.io.OutputStream;
|
|||
|
||||
import org.bouncycastle.openpgp.PGPException;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.implementation.ImplementationFactory;
|
||||
import org.pgpainless.util.Passphrase;
|
||||
import org.pgpainless.util.TestImplementationFactoryProvider;
|
||||
|
||||
public class EncryptionStreamClosedTest {
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void testStreamHasToBeClosedBeforeGetResultCanBeCalled(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
OutputStream out = new ByteArrayOutputStream();
|
||||
|
|
|
@ -26,9 +26,8 @@ import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
|||
import org.bouncycastle.openpgp.PGPSecretKeyRingCollection;
|
||||
import org.bouncycastle.openpgp.PGPSignature;
|
||||
import org.bouncycastle.util.io.Streams;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.algorithm.DocumentSignatureType;
|
||||
import org.pgpainless.algorithm.HashAlgorithm;
|
||||
|
@ -49,11 +48,12 @@ import org.pgpainless.key.protection.SecretKeyRingProtector;
|
|||
import org.pgpainless.key.util.KeyRingUtils;
|
||||
import org.pgpainless.util.MultiMap;
|
||||
import org.pgpainless.util.Passphrase;
|
||||
import org.pgpainless.util.TestImplementationFactoryProvider;
|
||||
|
||||
public class SigningTest {
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void testEncryptionAndSignatureVerification(ImplementationFactory implementationFactory)
|
||||
throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
@ -117,9 +117,11 @@ public class SigningTest {
|
|||
assertFalse(metadata.containsVerifiedSignatureFrom(julietKeys));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSignWithInvalidUserIdFails()
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void testSignWithInvalidUserIdFails(ImplementationFactory implementationFactory)
|
||||
throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
PGPSecretKeyRing secretKeys = PGPainless.generateKeyRing()
|
||||
.modernKeyRing("alice", "password123");
|
||||
SecretKeyRingProtector protector = SecretKeyRingProtector.unlockAnyKeyWith(Passphrase.fromPassword("password123"));
|
||||
|
@ -131,9 +133,11 @@ public class SigningTest {
|
|||
DocumentSignatureType.CANONICAL_TEXT_DOCUMENT));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSignWithRevokedUserIdFails()
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void testSignWithRevokedUserIdFails(ImplementationFactory implementationFactory)
|
||||
throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
PGPSecretKeyRing secretKeys = PGPainless.generateKeyRing()
|
||||
.modernKeyRing("alice", "password123");
|
||||
SecretKeyRingProtector protector = SecretKeyRingProtector.unlockAnyKeyWith(
|
||||
|
@ -151,8 +155,10 @@ public class SigningTest {
|
|||
DocumentSignatureType.CANONICAL_TEXT_DOCUMENT));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void signWithHashAlgorithmOverride() throws PGPException, IOException {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void signWithHashAlgorithmOverride(ImplementationFactory implementationFactory) throws PGPException, IOException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
PGPSecretKeyRing secretKeys = TestKeys.getEmilSecretKeyRing();
|
||||
SecretKeyRingProtector protector = SecretKeyRingProtector.unprotectedKeys();
|
||||
|
||||
|
@ -182,9 +188,11 @@ public class SigningTest {
|
|||
assertEquals(HashAlgorithm.SHA224.getAlgorithmId(), signature.getHashAlgorithm());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void negotiateHashAlgorithmChoseFallbackIfEmptyPreferences()
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void negotiateHashAlgorithmChoseFallbackIfEmptyPreferences(ImplementationFactory implementationFactory)
|
||||
throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IOException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
PGPSecretKeyRing secretKeys = PGPainless.buildKeyRing()
|
||||
.setPrimaryKey(KeySpec.getBuilder(
|
||||
KeyType.EDDSA(EdDSACurve._Ed25519), KeyFlag.CERTIFY_OTHER, KeyFlag.SIGN_DATA)
|
||||
|
@ -211,9 +219,11 @@ public class SigningTest {
|
|||
signature.getHashAlgorithm());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void negotiateHashAlgorithmChoseFallbackIfUnacceptablePreferences()
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void negotiateHashAlgorithmChoseFallbackIfUnacceptablePreferences(ImplementationFactory implementationFactory)
|
||||
throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IOException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
PGPSecretKeyRing secretKeys = PGPainless.buildKeyRing()
|
||||
.setPrimaryKey(
|
||||
KeySpec.getBuilder(KeyType.EDDSA(EdDSACurve._Ed25519), KeyFlag.CERTIFY_OTHER, KeyFlag.SIGN_DATA)
|
||||
|
@ -240,9 +250,11 @@ public class SigningTest {
|
|||
signature.getHashAlgorithm());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void signingWithNonCapableKeyThrowsKeyCannotSignException()
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void signingWithNonCapableKeyThrowsKeyCannotSignException(ImplementationFactory implementationFactory)
|
||||
throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
PGPSecretKeyRing secretKeys = PGPainless.buildKeyRing()
|
||||
.setPrimaryKey(KeySpec.getBuilder(KeyType.EDDSA(EdDSACurve._Ed25519), KeyFlag.CERTIFY_OTHER))
|
||||
.addUserId("Alice")
|
||||
|
@ -255,9 +267,11 @@ public class SigningTest {
|
|||
SecretKeyRingProtector.unprotectedKeys(), secretKeys, DocumentSignatureType.BINARY_DOCUMENT));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void signWithInvalidUserIdThrowsKeyValidationError()
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void signWithInvalidUserIdThrowsKeyValidationError(ImplementationFactory implementationFactory)
|
||||
throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
PGPSecretKeyRing secretKeys = PGPainless.buildKeyRing()
|
||||
.setPrimaryKey(KeySpec.getBuilder(KeyType.EDDSA(EdDSACurve._Ed25519),
|
||||
KeyFlag.CERTIFY_OTHER, KeyFlag.SIGN_DATA))
|
||||
|
|
|
@ -30,14 +30,15 @@ import org.bouncycastle.openpgp.operator.jcajce.JcaPGPContentSignerBuilder;
|
|||
import org.bouncycastle.openpgp.operator.jcajce.JcaPGPDigestCalculatorProviderBuilder;
|
||||
import org.bouncycastle.openpgp.operator.jcajce.JcaPGPKeyPair;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
import org.pgpainless.implementation.ImplementationFactory;
|
||||
import org.pgpainless.provider.ProviderFactory;
|
||||
import org.pgpainless.util.TestImplementationFactoryProvider;
|
||||
|
||||
public class BouncycastleExportSubkeys {
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void testExportImport(ImplementationFactory implementationFactory) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
KeyPairGenerator generator;
|
||||
|
|
|
@ -14,8 +14,9 @@ import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
|||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.bouncycastle.openpgp.operator.KeyFingerPrintCalculator;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
import org.pgpainless.implementation.ImplementationFactory;
|
||||
import org.pgpainless.util.TestImplementationFactoryProvider;
|
||||
|
||||
public class ImportExportKeyTest {
|
||||
|
||||
|
@ -24,7 +25,7 @@ public class ImportExportKeyTest {
|
|||
* @throws IOException in case of a IO error
|
||||
*/
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void testExportImportPublicKeyRing(ImplementationFactory implementationFactory) throws IOException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
PGPPublicKeyRing publicKeys = TestKeys.getJulietPublicKeyRing();
|
||||
|
@ -36,7 +37,7 @@ public class ImportExportKeyTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void testExportImportSecretKeyRing(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
PGPSecretKeyRing secretKeys = TestKeys.getRomeoSecretKeyRing();
|
||||
|
|
|
@ -18,7 +18,7 @@ import org.bouncycastle.openpgp.PGPPublicKey;
|
|||
import org.bouncycastle.openpgp.PGPSecretKey;
|
||||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.algorithm.KeyFlag;
|
||||
import org.pgpainless.algorithm.PublicKeyAlgorithm;
|
||||
|
@ -32,11 +32,12 @@ import org.pgpainless.key.info.KeyInfo;
|
|||
import org.pgpainless.key.util.UserId;
|
||||
import org.pgpainless.util.BCUtil;
|
||||
import org.pgpainless.util.Passphrase;
|
||||
import org.pgpainless.util.TestImplementationFactoryProvider;
|
||||
|
||||
public class BrainpoolKeyGenerationTest {
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void generateEcKeysTest(ImplementationFactory implementationFactory)
|
||||
throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
@ -66,7 +67,7 @@ public class BrainpoolKeyGenerationTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void generateEdDSAKeyTest(ImplementationFactory implementationFactory)
|
||||
throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
|
|
@ -7,13 +7,14 @@ package org.pgpainless.key.generation;
|
|||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.algorithm.KeyFlag;
|
||||
import org.pgpainless.implementation.ImplementationFactory;
|
||||
import org.pgpainless.key.generation.type.KeyType;
|
||||
import org.pgpainless.key.generation.type.ecc.EllipticCurve;
|
||||
import org.pgpainless.key.generation.type.xdh.XDHSpec;
|
||||
import org.pgpainless.util.TestImplementationFactoryProvider;
|
||||
|
||||
public class CertificationKeyMustBeAbleToCertifyTest {
|
||||
|
||||
|
@ -23,7 +24,7 @@ public class CertificationKeyMustBeAbleToCertifyTest {
|
|||
* This test therefore verifies that generating such keys fails.
|
||||
*/
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void testCertificationIncapableKeyTypesThrow(ImplementationFactory implementationFactory) {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
KeyType[] typesIncapableOfCreatingVerifications = new KeyType[] {
|
||||
|
|
|
@ -13,7 +13,7 @@ import java.security.NoSuchAlgorithmException;
|
|||
import org.bouncycastle.openpgp.PGPException;
|
||||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.algorithm.KeyFlag;
|
||||
import org.pgpainless.algorithm.PublicKeyAlgorithm;
|
||||
|
@ -24,11 +24,12 @@ import org.pgpainless.key.generation.type.xdh.XDHSpec;
|
|||
import org.pgpainless.key.protection.SecretKeyRingProtector;
|
||||
import org.pgpainless.key.protection.UnlockSecretKey;
|
||||
import org.pgpainless.key.util.UserId;
|
||||
import org.pgpainless.util.TestImplementationFactoryProvider;
|
||||
|
||||
public class GenerateEllipticCurveKeyTest {
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void generateEllipticCurveKeys(ImplementationFactory implementationFactory) throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, PGPException, IOException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
PGPSecretKeyRing keyRing = PGPainless.buildKeyRing()
|
||||
|
|
|
@ -18,7 +18,7 @@ import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
|||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.junit.JUtils;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.algorithm.KeyFlag;
|
||||
import org.pgpainless.implementation.ImplementationFactory;
|
||||
|
@ -27,11 +27,12 @@ import org.pgpainless.key.generation.type.rsa.RsaLength;
|
|||
import org.pgpainless.key.util.KeyRingUtils;
|
||||
import org.pgpainless.key.util.UserId;
|
||||
import org.pgpainless.util.DateUtil;
|
||||
import org.pgpainless.util.TestImplementationFactoryProvider;
|
||||
|
||||
public class GenerateKeyWithAdditionalUserIdTest {
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void test(ImplementationFactory implementationFactory) throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, PGPException, IOException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
Date expiration = new Date(DateUtil.now().getTime() + 60 * 1000);
|
||||
|
|
|
@ -12,13 +12,14 @@ import java.security.NoSuchAlgorithmException;
|
|||
|
||||
import org.bouncycastle.openpgp.PGPException;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.algorithm.KeyFlag;
|
||||
import org.pgpainless.implementation.ImplementationFactory;
|
||||
import org.pgpainless.key.generation.type.KeyType;
|
||||
import org.pgpainless.key.generation.type.rsa.RsaLength;
|
||||
import org.pgpainless.util.Passphrase;
|
||||
import org.pgpainless.util.TestImplementationFactoryProvider;
|
||||
|
||||
/**
|
||||
* Reproduce behavior of https://github.com/pgpainless/pgpainless/issues/16
|
||||
|
@ -30,7 +31,7 @@ import org.pgpainless.util.Passphrase;
|
|||
public class GenerateWithEmptyPassphraseTest {
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void testGeneratingKeyWithEmptyPassphraseDoesNotThrow(ImplementationFactory implementationFactory) throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, PGPException, IOException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
|
|
@ -7,17 +7,18 @@ package org.pgpainless.key.generation;
|
|||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
import org.pgpainless.algorithm.KeyFlag;
|
||||
import org.pgpainless.implementation.ImplementationFactory;
|
||||
import org.pgpainless.key.generation.type.KeyType;
|
||||
import org.pgpainless.key.generation.type.eddsa.EdDSACurve;
|
||||
import org.pgpainless.key.generation.type.xdh.XDHSpec;
|
||||
import org.pgpainless.util.TestImplementationFactoryProvider;
|
||||
|
||||
public class IllegalKeyFlagsTest {
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void testKeyCannotCarryFlagsTest(ImplementationFactory implementationFactory) {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
assertThrows(IllegalArgumentException.class, () -> KeySpec.getBuilder(
|
||||
|
|
|
@ -32,7 +32,7 @@ import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
|||
import org.junit.JUtils;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.algorithm.CompressionAlgorithm;
|
||||
import org.pgpainless.algorithm.EncryptionPurpose;
|
||||
|
@ -53,11 +53,12 @@ import org.pgpainless.key.util.KeyRingUtils;
|
|||
import org.pgpainless.key.util.UserId;
|
||||
import org.pgpainless.util.DateUtil;
|
||||
import org.pgpainless.util.Passphrase;
|
||||
import org.pgpainless.util.TestImplementationFactoryProvider;
|
||||
|
||||
public class KeyRingInfoTest {
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void testWithEmilsKeys(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -175,8 +176,8 @@ public class KeyRingInfoTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
public void dummyS2KTest(ImplementationFactory implementationFactory) throws PGPException, IOException {
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void dummyS2KTest(ImplementationFactory implementationFactory) throws IOException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
String withDummyS2K = "-----BEGIN PGP PRIVATE KEY BLOCK-----\n" +
|
||||
|
@ -214,7 +215,7 @@ public class KeyRingInfoTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void testGetKeysWithFlagsAndExpiry(ImplementationFactory implementationFactory) throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ import org.bouncycastle.openpgp.PGPPublicKey;
|
|||
import org.bouncycastle.openpgp.PGPSecretKey;
|
||||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.algorithm.KeyFlag;
|
||||
import org.pgpainless.implementation.ImplementationFactory;
|
||||
|
@ -34,11 +34,12 @@ import org.pgpainless.key.protection.PasswordBasedSecretKeyRingProtector;
|
|||
import org.pgpainless.key.protection.SecretKeyRingProtector;
|
||||
import org.pgpainless.key.protection.UnlockSecretKey;
|
||||
import org.pgpainless.util.Passphrase;
|
||||
import org.pgpainless.util.TestImplementationFactoryProvider;
|
||||
|
||||
public class AddSubKeyTest {
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void testAddSubKey(ImplementationFactory implementationFactory) throws IOException, PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
PGPSecretKeyRing secretKeys = TestKeys.getCryptieSecretKeyRing();
|
||||
|
|
|
@ -19,7 +19,7 @@ import org.bouncycastle.openpgp.PGPException;
|
|||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.implementation.ImplementationFactory;
|
||||
import org.pgpainless.key.TestKeys;
|
||||
|
@ -29,12 +29,14 @@ import org.pgpainless.key.protection.SecretKeyRingProtector;
|
|||
import org.pgpainless.key.protection.UnprotectedKeysProtector;
|
||||
import org.pgpainless.key.util.UserId;
|
||||
import org.pgpainless.util.Passphrase;
|
||||
import org.pgpainless.util.TestImplementationFactoryProvider;
|
||||
|
||||
public class AddUserIdTest {
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
public void addUserIdToExistingKeyRing(ImplementationFactory implementationFactory) throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, PGPException, InterruptedException {
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void addUserIdToExistingKeyRing(ImplementationFactory implementationFactory)
|
||||
throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
PGPSecretKeyRing secretKeys = PGPainless.generateKeyRing().simpleEcKeyRing("alice@wonderland.lit", "rabb1th0le");
|
||||
|
||||
|
@ -65,7 +67,7 @@ public class AddUserIdTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void deleteUserId_noSuchElementExceptionForMissingUserId(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -75,7 +77,7 @@ public class AddUserIdTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void deleteExistingAndAddNewUserIdToExistingKeyRing(ImplementationFactory implementationFactory) throws PGPException, IOException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
|
|
@ -11,11 +11,12 @@ import org.bouncycastle.openpgp.PGPException;
|
|||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.junit.JUtils;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.implementation.ImplementationFactory;
|
||||
import org.pgpainless.key.protection.SecretKeyRingProtector;
|
||||
import org.pgpainless.util.DateUtil;
|
||||
import org.pgpainless.util.TestImplementationFactoryProvider;
|
||||
|
||||
public class ChangeExpirationOnKeyWithDifferentSignatureTypesTest {
|
||||
|
||||
|
@ -136,7 +137,7 @@ public class ChangeExpirationOnKeyWithDifferentSignatureTypesTest {
|
|||
"-----END PGP PRIVATE KEY BLOCK-----";
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void setExpirationDate_keyHasSigClass10(ImplementationFactory implementationFactory)
|
||||
throws PGPException, IOException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
@ -146,7 +147,7 @@ public class ChangeExpirationOnKeyWithDifferentSignatureTypesTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void setExpirationDate_keyHasSigClass12(ImplementationFactory implementationFactory)
|
||||
throws PGPException, IOException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
|
|
@ -14,7 +14,7 @@ import java.util.Date;
|
|||
import org.bouncycastle.openpgp.PGPException;
|
||||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.implementation.ImplementationFactory;
|
||||
import org.pgpainless.key.OpenPgpV4Fingerprint;
|
||||
|
@ -22,14 +22,16 @@ import org.pgpainless.key.TestKeys;
|
|||
import org.pgpainless.key.info.KeyRingInfo;
|
||||
import org.pgpainless.key.protection.UnprotectedKeysProtector;
|
||||
import org.pgpainless.util.DateUtil;
|
||||
import org.pgpainless.util.TestImplementationFactoryProvider;
|
||||
|
||||
public class ChangeExpirationTest {
|
||||
|
||||
private final OpenPgpV4Fingerprint subKeyFingerprint = new OpenPgpV4Fingerprint("F73FDE6439ABE210B1AF4EDD273EF7A0C749807B");
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
public void setExpirationDateAndThenUnsetIt_OnPrimaryKey(ImplementationFactory implementationFactory) throws PGPException, IOException, InterruptedException {
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void setExpirationDateAndThenUnsetIt_OnPrimaryKey(ImplementationFactory implementationFactory)
|
||||
throws PGPException, IOException, InterruptedException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
PGPSecretKeyRing secretKeys = TestKeys.getEmilSecretKeyRing();
|
||||
|
@ -61,8 +63,9 @@ public class ChangeExpirationTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
public void setExpirationDateAndThenUnsetIt_OnSubkey(ImplementationFactory implementationFactory) throws PGPException, IOException, InterruptedException {
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void setExpirationDateAndThenUnsetIt_OnSubkey(ImplementationFactory implementationFactory)
|
||||
throws PGPException, IOException, InterruptedException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
PGPSecretKeyRing secretKeys = TestKeys.getEmilSecretKeyRing();
|
||||
|
|
|
@ -21,7 +21,7 @@ import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
|||
import org.bouncycastle.openpgp.operator.PBESecretKeyDecryptor;
|
||||
import org.bouncycastle.util.io.Streams;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.algorithm.DocumentSignatureType;
|
||||
import org.pgpainless.algorithm.SymmetricKeyAlgorithm;
|
||||
|
@ -33,6 +33,7 @@ import org.pgpainless.key.protection.KeyRingProtectionSettings;
|
|||
import org.pgpainless.key.protection.PasswordBasedSecretKeyRingProtector;
|
||||
import org.pgpainless.key.protection.UnlockSecretKey;
|
||||
import org.pgpainless.util.Passphrase;
|
||||
import org.pgpainless.util.TestImplementationFactoryProvider;
|
||||
|
||||
public class ChangeSecretKeyRingPassphraseTest {
|
||||
|
||||
|
@ -42,7 +43,7 @@ public class ChangeSecretKeyRingPassphraseTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void changePassphraseOfWholeKeyRingTest(ImplementationFactory implementationFactory) throws PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -70,7 +71,7 @@ public class ChangeSecretKeyRingPassphraseTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void changePassphraseOfWholeKeyRingToEmptyPassphrase(ImplementationFactory implementationFactory) throws PGPException, IOException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
PGPSecretKeyRing secretKeys = PGPainless.modifyKeyRing(keyRing)
|
||||
|
@ -88,7 +89,7 @@ public class ChangeSecretKeyRingPassphraseTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void changePassphraseOfSingleSubkeyToNewPassphrase(ImplementationFactory implementationFactory) throws PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -125,7 +126,7 @@ public class ChangeSecretKeyRingPassphraseTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void changePassphraseOfSingleSubkeyToEmptyPassphrase(ImplementationFactory implementationFactory) throws PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
|||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Date;
|
||||
|
@ -18,18 +17,19 @@ import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
|||
import org.bouncycastle.openpgp.PGPSignature;
|
||||
import org.bouncycastle.openpgp.PGPSignatureSubpacketVector;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.implementation.ImplementationFactory;
|
||||
import org.pgpainless.key.OpenPgpV4Fingerprint;
|
||||
import org.pgpainless.key.protection.UnprotectedKeysProtector;
|
||||
import org.pgpainless.util.TestImplementationFactoryProvider;
|
||||
|
||||
public class OldSignatureSubpacketsArePreservedOnNewSig {
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void verifyOldSignatureSubpacketsArePreservedOnNewExpirationDateSig(ImplementationFactory implementationFactory)
|
||||
throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, PGPException, InterruptedException, IOException {
|
||||
throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, PGPException, InterruptedException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
PGPSecretKeyRing secretKeys = PGPainless.generateKeyRing()
|
||||
.simpleEcKeyRing("Alice <alice@wonderland.lit>");
|
||||
|
|
|
@ -15,11 +15,12 @@ import org.bouncycastle.openpgp.PGPPublicKey;
|
|||
import org.bouncycastle.openpgp.PGPSecretKey;
|
||||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.implementation.ImplementationFactory;
|
||||
import org.pgpainless.key.protection.UnprotectedKeysProtector;
|
||||
import org.pgpainless.util.ArmoredOutputStreamFactory;
|
||||
import org.pgpainless.util.TestImplementationFactoryProvider;
|
||||
|
||||
/**
|
||||
* Test that makes sure that PGPainless can deal with keys that carry a key
|
||||
|
@ -64,7 +65,7 @@ public class RevokeKeyWithGenericCertificationSignatureTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void test(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
revokeKey(SAMPLE_PRIVATE_KEY); // would crash previously
|
||||
|
|
|
@ -14,7 +14,7 @@ import org.bouncycastle.openpgp.PGPSecretKey;
|
|||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.junit.JUtils;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.implementation.ImplementationFactory;
|
||||
import org.pgpainless.key.OpenPgpV4Fingerprint;
|
||||
|
@ -23,6 +23,7 @@ import org.pgpainless.key.modification.secretkeyring.SecretKeyRingEditorInterfac
|
|||
import org.pgpainless.key.protection.SecretKeyRingProtector;
|
||||
import org.pgpainless.key.protection.UnprotectedKeysProtector;
|
||||
import org.pgpainless.util.DateUtil;
|
||||
import org.pgpainless.util.TestImplementationFactoryProvider;
|
||||
|
||||
public class RevokeKeyWithoutPreferredAlgorithmsOnPrimaryKey {
|
||||
|
||||
|
@ -101,8 +102,9 @@ public class RevokeKeyWithoutPreferredAlgorithmsOnPrimaryKey {
|
|||
"-----END PGP PRIVATE KEY BLOCK-----";
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
public void testChangingExpirationTimeWithKeyWithoutPrefAlgos(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void testChangingExpirationTimeWithKeyWithoutPrefAlgos(ImplementationFactory implementationFactory)
|
||||
throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
Date expirationDate = DateUtil.parseUTCDate(DateUtil.formatUTCDate(new Date()));
|
||||
PGPSecretKeyRing secretKeys = PGPainless.readKeyRing().secretKeyRing(KEY);
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
|||
import org.bouncycastle.openpgp.PGPSignature;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.algorithm.EncryptionPurpose;
|
||||
import org.pgpainless.algorithm.SignatureType;
|
||||
|
@ -40,11 +40,12 @@ import org.pgpainless.signature.SignatureUtils;
|
|||
import org.pgpainless.signature.subpackets.RevocationSignatureSubpackets;
|
||||
import org.pgpainless.signature.subpackets.SignatureSubpacketsUtil;
|
||||
import org.pgpainless.util.Passphrase;
|
||||
import org.pgpainless.util.TestImplementationFactoryProvider;
|
||||
|
||||
public class RevokeSubKeyTest {
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void revokeSukeyTest(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
PGPSecretKeyRing secretKeys = TestKeys.getCryptieSecretKeyRing();
|
||||
|
@ -69,7 +70,7 @@ public class RevokeSubKeyTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void detachedRevokeSubkeyTest(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
PGPSecretKeyRing secretKeys = TestKeys.getCryptieSecretKeyRing();
|
||||
|
@ -90,7 +91,7 @@ public class RevokeSubKeyTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void testRevocationSignatureTypeCorrect(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
PGPSecretKeyRing secretKeys = TestKeys.getCryptieSecretKeyRing();
|
||||
|
|
|
@ -16,7 +16,6 @@ import java.util.Iterator;
|
|||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.bouncycastle.openpgp.PGPException;
|
||||
|
@ -25,17 +24,18 @@ import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
|||
import org.bouncycastle.openpgp.operator.PBESecretKeyDecryptor;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.implementation.ImplementationFactory;
|
||||
import org.pgpainless.key.TestKeys;
|
||||
import org.pgpainless.key.protection.passphrase_provider.SecretKeyPassphraseProvider;
|
||||
import org.pgpainless.util.Passphrase;
|
||||
import org.pgpainless.util.TestImplementationFactoryProvider;
|
||||
|
||||
public class SecretKeyRingProtectorTest {
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void testUnlockAllKeysWithSamePassword(ImplementationFactory implementationFactory)
|
||||
throws IOException, PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
@ -70,7 +70,7 @@ public class SecretKeyRingProtectorTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void testUnlockSingleKeyWithPassphrase(ImplementationFactory implementationFactory)
|
||||
throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
|
|
@ -17,12 +17,13 @@ import org.bouncycastle.openpgp.PGPException;
|
|||
import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
||||
import org.bouncycastle.openpgp.PGPSignature;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.exception.SignatureValidationException;
|
||||
import org.pgpainless.implementation.ImplementationFactory;
|
||||
import org.pgpainless.policy.Policy;
|
||||
import org.pgpainless.signature.consumer.CertificateValidator;
|
||||
import org.pgpainless.util.TestImplementationFactoryProvider;
|
||||
|
||||
/**
|
||||
* Explores how subpackets on binding sigs are handled.
|
||||
|
@ -52,7 +53,7 @@ public class BindingSignatureSubpacketsTest {
|
|||
private Policy policy = PGPainless.getPolicy();
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void baseCase(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -114,7 +115,7 @@ public class BindingSignatureSubpacketsTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void subkeyBindingIssuerFpOnly(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -176,7 +177,7 @@ public class BindingSignatureSubpacketsTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void subkeyBindingIssuerV6IssuerFp(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -238,7 +239,7 @@ public class BindingSignatureSubpacketsTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void subkeyBindingIssuerFakeIssuer(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -300,7 +301,7 @@ public class BindingSignatureSubpacketsTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void subkeyBindingFakeIssuerIssuer(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -362,7 +363,7 @@ public class BindingSignatureSubpacketsTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void subkeyBindingFakeIssuer(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -424,7 +425,7 @@ public class BindingSignatureSubpacketsTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void subkeyBindingNoIssuer(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -485,7 +486,7 @@ public class BindingSignatureSubpacketsTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void unknownSubpacketHashed(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -547,7 +548,7 @@ public class BindingSignatureSubpacketsTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void subkeyBindingUnknownCriticalSubpacket(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -609,7 +610,7 @@ public class BindingSignatureSubpacketsTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void subkeyBindingUnknownSubpacketUnhashed(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -671,7 +672,7 @@ public class BindingSignatureSubpacketsTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void subkeyBindingUnknownCriticalSubpacketUnhashed(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -733,7 +734,7 @@ public class BindingSignatureSubpacketsTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void subkeyBindingUnknownNotationHashed(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -796,7 +797,7 @@ public class BindingSignatureSubpacketsTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void subkeyBindingCriticalUnknownNotationHashed(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -859,7 +860,7 @@ public class BindingSignatureSubpacketsTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void subkeyBindingUnknownNotationUnhashed(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -922,7 +923,7 @@ public class BindingSignatureSubpacketsTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void subkeyBindingCriticalUnknownNotationUnhashed(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -985,7 +986,7 @@ public class BindingSignatureSubpacketsTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void subkeyBindingBackSigFakeBackSig(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -1058,7 +1059,7 @@ public class BindingSignatureSubpacketsTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void subkeyBindingFakeBackSigBackSig(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -1131,7 +1132,7 @@ public class BindingSignatureSubpacketsTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void primaryBindingIssuerFpOnly(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -1193,7 +1194,7 @@ public class BindingSignatureSubpacketsTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void primaryBindingIssuerV6IssuerFp(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -1255,7 +1256,7 @@ public class BindingSignatureSubpacketsTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void primaryBindingIssuerFakeIssuer(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -1317,7 +1318,7 @@ public class BindingSignatureSubpacketsTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void primaryBindingFakeIssuerIssuer(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -1379,7 +1380,7 @@ public class BindingSignatureSubpacketsTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void primaryBindingFakeIssuer(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -1441,7 +1442,7 @@ public class BindingSignatureSubpacketsTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void primaryBindingNoIssuer(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -1502,7 +1503,7 @@ public class BindingSignatureSubpacketsTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void primaryBindingUnknownSubpacketHashed(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -1564,7 +1565,7 @@ public class BindingSignatureSubpacketsTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void primaryBindingCriticalUnknownSubpacketHashed(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -1626,7 +1627,7 @@ public class BindingSignatureSubpacketsTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void primaryBindingUnknownSubpacketUnhashed(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -1688,7 +1689,7 @@ public class BindingSignatureSubpacketsTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void primaryBindingCriticalUnknownSubpacketUnhashed(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -1750,7 +1751,7 @@ public class BindingSignatureSubpacketsTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void primaryBindingUnknownNotationHashed(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -1813,7 +1814,7 @@ public class BindingSignatureSubpacketsTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void primaryBindingCriticalUnknownNotationHashed(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -1876,7 +1877,7 @@ public class BindingSignatureSubpacketsTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void primaryBindingUnknownNotationUnhashed(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -1939,7 +1940,7 @@ public class BindingSignatureSubpacketsTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void primaryBindingCriticalUnknownNotationUnhashed(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.bouncycastle.openpgp.PGPSignature;
|
|||
import org.bouncycastle.util.io.Streams;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.decryption_verification.ConsumerOptions;
|
||||
import org.pgpainless.decryption_verification.DecryptionStream;
|
||||
|
@ -29,6 +29,7 @@ import org.pgpainless.exception.SignatureValidationException;
|
|||
import org.pgpainless.implementation.ImplementationFactory;
|
||||
import org.pgpainless.policy.Policy;
|
||||
import org.pgpainless.signature.consumer.CertificateValidator;
|
||||
import org.pgpainless.util.TestImplementationFactoryProvider;
|
||||
|
||||
public class CertificateValidatorTest {
|
||||
|
||||
|
@ -38,7 +39,7 @@ public class CertificateValidatorTest {
|
|||
* @see <a href="https://tests.sequoia-pgp.org/#Key_revocation_test__primary_key_signs_and_is_revoked__revoked__unknown">Sequoia Test Suite</a>
|
||||
*/
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void testPrimaryKeySignsAndIsHardRevokedUnknown(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -190,7 +191,7 @@ public class CertificateValidatorTest {
|
|||
* @see <a href="https://tests.sequoia-pgp.org/#Key_revocation_test__subkey_signs__primary_key_is_revoked__revoked__unknown">Sequoia Test Suite</a>
|
||||
*/
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void testSubkeySignsPrimaryKeyIsHardRevokedUnknown(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -343,7 +344,7 @@ public class CertificateValidatorTest {
|
|||
* @see <a href="https://tests.sequoia-pgp.org/#Key_revocation_test__subkey_signs__subkey_is_revoked__revoked__unknown">Sequoia Test Suite</a>
|
||||
*/
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void testSubkeySignsAndIsHardRevokedUnknown(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -496,7 +497,7 @@ public class CertificateValidatorTest {
|
|||
* @see <a href="https://tests.sequoia-pgp.org/#Key_revocation_test__primary_key_signs_and_is_revoked__revoked__superseded">Sequoia Test Suite</a>
|
||||
*/
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void testPrimaryKeySignsAndIsSoftRevokedSuperseded(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -654,7 +655,7 @@ public class CertificateValidatorTest {
|
|||
* @see <a href="https://tests.sequoia-pgp.org/#Key_revocation_test__subkey_signs__primary_key_is_revoked__revoked__superseded">Sequoia Test Suite</a>
|
||||
*/
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void testSubkeySignsPrimaryKeyIsSoftRevokedSuperseded(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -808,7 +809,7 @@ public class CertificateValidatorTest {
|
|||
* @see <a href="https://tests.sequoia-pgp.org/#Key_revocation_test__primary_key_signs_and_is_revoked__revoked__key_retired">Sequoia Test Suite</a>
|
||||
*/
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void testPrimaryKeySignsAndIsSoftRevokedRetired(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -962,7 +963,7 @@ public class CertificateValidatorTest {
|
|||
* @see <a href="https://tests.sequoia-pgp.org/#Temporary_validity">Sequoia Test Suite</a>
|
||||
*/
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void testTemporaryValidity(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
|
|
@ -15,18 +15,19 @@ import org.bouncycastle.openpgp.PGPException;
|
|||
import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
||||
import org.bouncycastle.openpgp.PGPSignature;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.exception.SignatureValidationException;
|
||||
import org.pgpainless.implementation.ImplementationFactory;
|
||||
import org.pgpainless.signature.consumer.CertificateValidator;
|
||||
import org.pgpainless.util.TestImplementationFactoryProvider;
|
||||
|
||||
public class KeyRevocationTest {
|
||||
|
||||
private static final String data = "Hello, World";
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void subkeySignsPrimaryKeyRevokedNoReason(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
@ -174,7 +175,7 @@ public class KeyRevocationTest {
|
|||
* @see <a href="https://tests.sequoia-pgp.org/#Key_revocation_test__subkey_signs__primary_key_is_not_revoked__base_case_">Sequoia Test-Suite</a>
|
||||
*/
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void subkeySignsPrimaryKeyNotRevoked(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ import org.bouncycastle.openpgp.PGPUtil;
|
|||
import org.bouncycastle.openpgp.operator.PublicKeyDataDecryptorFactory;
|
||||
import org.bouncycastle.util.io.Streams;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.algorithm.DocumentSignatureType;
|
||||
import org.pgpainless.algorithm.HashAlgorithm;
|
||||
|
@ -47,11 +47,12 @@ import org.pgpainless.encryption_signing.SigningOptions;
|
|||
import org.pgpainless.implementation.ImplementationFactory;
|
||||
import org.pgpainless.key.protection.SecretKeyRingProtector;
|
||||
import org.pgpainless.key.protection.UnlockSecretKey;
|
||||
import org.pgpainless.util.TestImplementationFactoryProvider;
|
||||
|
||||
public class OnePassSignatureBracketingTest {
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void onePassSignaturePacketsAndSignaturesAreBracketedTest(ImplementationFactory implementationFactory) throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IOException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import java.nio.charset.StandardCharsets;
|
|||
import org.bouncycastle.openpgp.PGPException;
|
||||
import org.bouncycastle.util.io.Streams;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.decryption_verification.ConsumerOptions;
|
||||
import org.pgpainless.decryption_verification.DecryptionStream;
|
||||
|
@ -21,11 +21,12 @@ import org.pgpainless.encryption_signing.EncryptionStream;
|
|||
import org.pgpainless.encryption_signing.ProducerOptions;
|
||||
import org.pgpainless.implementation.ImplementationFactory;
|
||||
import org.pgpainless.util.Passphrase;
|
||||
import org.pgpainless.util.TestImplementationFactoryProvider;
|
||||
|
||||
public class MultiPassphraseSymmetricEncryptionTest {
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void encryptDecryptWithMultiplePassphrases(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
String message = "Here we test if during decryption of a message that was encrypted with two passphrases, " +
|
||||
|
|
|
@ -18,7 +18,7 @@ import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
|||
import org.bouncycastle.openpgp.PGPSecretKeyRingCollection;
|
||||
import org.bouncycastle.util.io.Streams;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.decryption_verification.ConsumerOptions;
|
||||
import org.pgpainless.decryption_verification.DecryptionStream;
|
||||
|
@ -34,6 +34,7 @@ import org.pgpainless.key.protection.PasswordBasedSecretKeyRingProtector;
|
|||
import org.pgpainless.key.protection.SecretKeyRingProtector;
|
||||
import org.pgpainless.key.protection.passphrase_provider.SolitaryPassphraseProvider;
|
||||
import org.pgpainless.util.Passphrase;
|
||||
import org.pgpainless.util.TestImplementationFactoryProvider;
|
||||
|
||||
/**
|
||||
* Test parallel symmetric and public key encryption/decryption.
|
||||
|
@ -41,7 +42,7 @@ import org.pgpainless.util.Passphrase;
|
|||
public class SymmetricEncryptionTest {
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void encryptWithKeyAndPassphrase_DecryptWithKey(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
byte[] plaintext = "This is a secret message".getBytes(StandardCharsets.UTF_8);
|
||||
|
@ -95,7 +96,7 @@ public class SymmetricEncryptionTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void testMismatchPassphraseFails(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.bouncycastle.util.io.Streams;
|
|||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
import org.pgpainless.algorithm.HashAlgorithm;
|
||||
import org.pgpainless.implementation.ImplementationFactory;
|
||||
import org.pgpainless.key.TestKeys;
|
||||
|
@ -145,7 +145,7 @@ public class ArmorUtilsTest {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
|
||||
@ArgumentsSource(TestImplementationFactoryProvider.class)
|
||||
public void decodeExampleTest(ImplementationFactory implementationFactory) throws IOException, PGPException {
|
||||
ImplementationFactory.setFactoryImplementation(implementationFactory);
|
||||
String armored = "-----BEGIN PGP MESSAGE-----\n" +
|
||||
|
|
|
@ -4,24 +4,29 @@
|
|||
|
||||
package org.pgpainless.util;
|
||||
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.ArgumentsProvider;
|
||||
import org.pgpainless.implementation.BcImplementationFactory;
|
||||
import org.pgpainless.implementation.ImplementationFactory;
|
||||
import org.pgpainless.implementation.JceImplementationFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* Utility class used to provide all available implementations of {@link ImplementationFactory} for parametrized tests.
|
||||
*/
|
||||
public class TestImplementationFactoryProvider {
|
||||
public class TestImplementationFactoryProvider implements ArgumentsProvider {
|
||||
|
||||
private static final List<ImplementationFactory> IMPLEMENTATIONS = Arrays.asList(
|
||||
new BcImplementationFactory(),
|
||||
new JceImplementationFactory()
|
||||
);
|
||||
|
||||
public static List<ImplementationFactory> provideImplementationFactories() {
|
||||
return IMPLEMENTATIONS;
|
||||
@Override
|
||||
public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
|
||||
return IMPLEMENTATIONS.stream().map(Arguments::of);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue