1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-11-22 20:32:05 +01:00

Improve tests

This commit is contained in:
Paul Schaub 2018-07-25 16:53:00 +02:00
parent 4dbb4311ad
commit f6e523685b
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
6 changed files with 10 additions and 26 deletions

View file

@ -15,13 +15,11 @@
*/ */
package org.pgpainless; package org.pgpainless;
import java.io.IOException;
import java.security.InvalidAlgorithmParameterException; import java.security.InvalidAlgorithmParameterException;
import java.security.KeyPair; import java.security.KeyPair;
import java.security.KeyPairGenerator; import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException; import java.security.NoSuchProviderException;
import java.security.Security;
import java.util.Date; import java.util.Date;
import org.bouncycastle.bcpg.CompressionAlgorithmTags; import org.bouncycastle.bcpg.CompressionAlgorithmTags;
@ -46,12 +44,10 @@ import org.bouncycastle.openpgp.operator.jcajce.JcaPGPDigestCalculatorProviderBu
import org.bouncycastle.openpgp.operator.jcajce.JcaPGPKeyPair; import org.bouncycastle.openpgp.operator.jcajce.JcaPGPKeyPair;
import org.junit.Test; import org.junit.Test;
public class BouncycastleExportSubkeys { public class BouncycastleExportSubkeys extends AbstractPGPainlessTest {
@Test @Test
public void testExportImport() throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException, PGPException, IOException { public void testExportImport() throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException, PGPException {
Security.addProvider(new BouncyCastleProvider());
KeyPairGenerator generator; KeyPairGenerator generator;
KeyPair pair; KeyPair pair;

View file

@ -21,11 +21,9 @@ import java.io.IOException;
import java.security.InvalidAlgorithmParameterException; import java.security.InvalidAlgorithmParameterException;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException; import java.security.NoSuchProviderException;
import java.security.Security;
import java.util.Arrays; import java.util.Arrays;
import java.util.Iterator; import java.util.Iterator;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPPublicKey; import org.bouncycastle.openpgp.PGPPublicKey;
import org.bouncycastle.openpgp.PGPPublicKeyRing; import org.bouncycastle.openpgp.PGPPublicKeyRing;
@ -34,14 +32,10 @@ import org.bouncycastle.openpgp.operator.bc.BcKeyFingerprintCalculator;
import org.junit.Test; import org.junit.Test;
import org.pgpainless.key.collection.PGPKeyRing; import org.pgpainless.key.collection.PGPKeyRing;
public class ImportExportKeyTest { public class ImportExportKeyTest extends AbstractPGPainlessTest {
static {
Security.addProvider(new BouncyCastleProvider());
}
/** /**
* This test is failing. Not sure if a bug in BC or in my code... * Test the export and import of a key ring with sub keys.
* @throws PGPException very * @throws PGPException very
* @throws NoSuchAlgorithmException much * @throws NoSuchAlgorithmException much
* @throws NoSuchProviderException some * @throws NoSuchProviderException some

View file

@ -21,10 +21,8 @@ import java.io.IOException;
import java.security.InvalidAlgorithmParameterException; import java.security.InvalidAlgorithmParameterException;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException; import java.security.NoSuchProviderException;
import java.security.Security;
import java.util.Arrays; import java.util.Arrays;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPPublicKeyRing; import org.bouncycastle.openpgp.PGPPublicKeyRing;
import org.bouncycastle.openpgp.PGPSecretKeyRing; import org.bouncycastle.openpgp.PGPSecretKeyRing;
@ -33,11 +31,7 @@ import org.pgpainless.key.collection.PGPKeyRing;
import org.pgpainless.util.BCUtil; import org.pgpainless.util.BCUtil;
import org.pgpainless.util.KeyRingSubKeyFix; import org.pgpainless.util.KeyRingSubKeyFix;
public class KeyRingSubKeyFixTest { public class KeyRingSubKeyFixTest extends AbstractPGPainlessTest {
static {
Security.addProvider(new BouncyCastleProvider());
}
@Test @Test
public void test() public void test()

View file

@ -66,11 +66,11 @@ public class LengthTest extends AbstractPGPainlessTest {
// @Test // @Test
public void RsaRsa4096() public void RsaRsa4096()
throws PGPException, NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException, throws PGPException,
IOException { IOException {
LOGGER.log(Level.INFO, "\nRSA-4096 -> RSA-4096"); LOGGER.log(Level.INFO, "\nRSA-4096 -> RSA-4096");
PGPKeyRing sender = PGPainless.generateKeyRing().simpleRsaKeyRing("simplejid@server.tld", RsaLength._4096); PGPKeyRing sender = PGPainless.readKeyRing().keyRing(TestKeys.JULIET_PUB, TestKeys.JULIET_SEC);
PGPKeyRing recipient = PGPainless.generateKeyRing().simpleRsaKeyRing("otherjid@other.srv", RsaLength._4096); PGPKeyRing recipient = PGPainless.readKeyRing().keyRing(TestKeys.ROMEO_PUB, TestKeys.ROMEO_SEC);
encryptDecryptForSecretKeyRings(sender, recipient); encryptDecryptForSecretKeyRings(sender, recipient);
} }

View file

@ -24,7 +24,7 @@ import org.bouncycastle.openpgp.PGPPublicKey;
import org.junit.Test; import org.junit.Test;
import org.pgpainless.key.OpenPgpV4Fingerprint; import org.pgpainless.key.OpenPgpV4Fingerprint;
public class OpenPgpV4FingerprintTest { public class OpenPgpV4FingerprintTest extends AbstractPGPainlessTest {
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void fpTooShort() { public void fpTooShort() {

View file

@ -27,7 +27,7 @@ import org.bouncycastle.openpgp.PGPUtil;
import org.bouncycastle.openpgp.operator.KeyFingerPrintCalculator; import org.bouncycastle.openpgp.operator.KeyFingerPrintCalculator;
import org.bouncycastle.openpgp.operator.bc.BcKeyFingerprintCalculator; import org.bouncycastle.openpgp.operator.bc.BcKeyFingerprintCalculator;
public class TestKeys { public class TestKeys extends AbstractPGPainlessTest {
private static final KeyFingerPrintCalculator calc = new BcKeyFingerprintCalculator(); private static final KeyFingerPrintCalculator calc = new BcKeyFingerprintCalculator();
private static PGPSecretKeyRing julietSecretKeyRing = null; private static PGPSecretKeyRing julietSecretKeyRing = null;