Skip to content

Commit

Permalink
Improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vanitasvitae committed Jul 25, 2018
1 parent 4dbb431 commit f6e5236
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 26 deletions.
Expand Up @@ -15,13 +15,11 @@
*/
package org.pgpainless;

import java.io.IOException;
import java.security.InvalidAlgorithmParameterException;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Security;
import java.util.Date;

import org.bouncycastle.bcpg.CompressionAlgorithmTags;
Expand All @@ -46,12 +44,10 @@
import org.bouncycastle.openpgp.operator.jcajce.JcaPGPKeyPair;
import org.junit.Test;

public class BouncycastleExportSubkeys {
public class BouncycastleExportSubkeys extends AbstractPGPainlessTest {

@Test
public void testExportImport() throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException, PGPException, IOException {
Security.addProvider(new BouncyCastleProvider());

public void testExportImport() throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException, PGPException {
KeyPairGenerator generator;
KeyPair pair;

Expand Down
Expand Up @@ -21,11 +21,9 @@
import java.security.InvalidAlgorithmParameterException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Security;
import java.util.Arrays;
import java.util.Iterator;

import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPPublicKey;
import org.bouncycastle.openpgp.PGPPublicKeyRing;
Expand All @@ -34,14 +32,10 @@
import org.junit.Test;
import org.pgpainless.key.collection.PGPKeyRing;

public class ImportExportKeyTest {

static {
Security.addProvider(new BouncyCastleProvider());
}
public class ImportExportKeyTest extends AbstractPGPainlessTest {

/**
* 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 NoSuchAlgorithmException much
* @throws NoSuchProviderException some
Expand Down
Expand Up @@ -21,10 +21,8 @@
import java.security.InvalidAlgorithmParameterException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Security;
import java.util.Arrays;

import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPPublicKeyRing;
import org.bouncycastle.openpgp.PGPSecretKeyRing;
Expand All @@ -33,11 +31,7 @@
import org.pgpainless.util.BCUtil;
import org.pgpainless.util.KeyRingSubKeyFix;

public class KeyRingSubKeyFixTest {

static {
Security.addProvider(new BouncyCastleProvider());
}
public class KeyRingSubKeyFixTest extends AbstractPGPainlessTest {

@Test
public void test()
Expand Down
6 changes: 3 additions & 3 deletions pgpainless-core/src/test/java/org/pgpainless/LengthTest.java
Expand Up @@ -66,11 +66,11 @@ public void RsaRsa()

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

Expand Down
Expand Up @@ -24,7 +24,7 @@
import org.junit.Test;
import org.pgpainless.key.OpenPgpV4Fingerprint;

public class OpenPgpV4FingerprintTest {
public class OpenPgpV4FingerprintTest extends AbstractPGPainlessTest {

@Test(expected = IllegalArgumentException.class)
public void fpTooShort() {
Expand Down
2 changes: 1 addition & 1 deletion pgpainless-core/src/test/java/org/pgpainless/TestKeys.java
Expand Up @@ -27,7 +27,7 @@
import org.bouncycastle.openpgp.operator.KeyFingerPrintCalculator;
import org.bouncycastle.openpgp.operator.bc.BcKeyFingerprintCalculator;

public class TestKeys {
public class TestKeys extends AbstractPGPainlessTest {

private static final KeyFingerPrintCalculator calc = new BcKeyFingerprintCalculator();
private static PGPSecretKeyRing julietSecretKeyRing = null;
Expand Down

0 comments on commit f6e5236

Please sign in to comment.