mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-26 22:32:07 +01:00
Merge pull request #21 from pgpainless/junit
Switch to Jupiter JUnit for tests
This commit is contained in:
commit
473f64f56f
30 changed files with 160 additions and 167 deletions
|
@ -53,7 +53,7 @@ allprojects {
|
||||||
}
|
}
|
||||||
|
|
||||||
project.ext {
|
project.ext {
|
||||||
junitVersion = 4.12
|
junitVersion = '5.7.0'
|
||||||
androidBootClasspath = getAndroidRuntimeJar(pgpainlessMinAndroidSdk)
|
androidBootClasspath = getAndroidRuntimeJar(pgpainlessMinAndroidSdk)
|
||||||
rootConfigDir = new File(rootDir, 'config')
|
rootConfigDir = new File(rootDir, 'config')
|
||||||
gitCommit = getGitCommit()
|
gitCommit = getGitCommit()
|
||||||
|
@ -92,6 +92,9 @@ allprojects {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test {
|
||||||
|
useJUnitPlatform()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
|
|
|
@ -3,7 +3,9 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
testImplementation group: 'junit', name: 'junit', version: '4.12'
|
testImplementation "org.junit.jupiter:junit-jupiter-api:$junitVersion"
|
||||||
|
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
implementation "org.bouncycastle:bcprov-debug-jdk15on:$bouncyCastleVersion"
|
implementation "org.bouncycastle:bcprov-debug-jdk15on:$bouncyCastleVersion"
|
||||||
/*/
|
/*/
|
||||||
|
|
|
@ -15,9 +15,9 @@
|
||||||
*/
|
*/
|
||||||
package org.pgpainless.decryption_verification;
|
package org.pgpainless.decryption_verification;
|
||||||
|
|
||||||
import static junit.framework.TestCase.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||||
import static junit.framework.TestCase.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
@ -30,8 +30,8 @@ import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
||||||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||||
import org.bouncycastle.openpgp.PGPSecretKeyRingCollection;
|
import org.bouncycastle.openpgp.PGPSecretKeyRingCollection;
|
||||||
import org.bouncycastle.util.io.Streams;
|
import org.bouncycastle.util.io.Streams;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.pgpainless.PGPainless;
|
import org.pgpainless.PGPainless;
|
||||||
import org.pgpainless.algorithm.CompressionAlgorithm;
|
import org.pgpainless.algorithm.CompressionAlgorithm;
|
||||||
import org.pgpainless.algorithm.SymmetricKeyAlgorithm;
|
import org.pgpainless.algorithm.SymmetricKeyAlgorithm;
|
||||||
|
@ -46,7 +46,7 @@ public class DecryptAndVerifyMessageTest {
|
||||||
private PGPSecretKeyRing juliet;
|
private PGPSecretKeyRing juliet;
|
||||||
private PGPSecretKeyRing romeo;
|
private PGPSecretKeyRing romeo;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void loadKeys() throws IOException, PGPException {
|
public void loadKeys() throws IOException, PGPException {
|
||||||
juliet = TestKeys.getJulietSecretKeyRing();
|
juliet = TestKeys.getJulietSecretKeyRing();
|
||||||
romeo = TestKeys.getRomeoSecretKeyRing();
|
romeo = TestKeys.getRomeoSecretKeyRing();
|
||||||
|
|
|
@ -15,10 +15,10 @@
|
||||||
*/
|
*/
|
||||||
package org.pgpainless.encryption_signing;
|
package org.pgpainless.encryption_signing;
|
||||||
|
|
||||||
import static junit.framework.TestCase.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||||
import static junit.framework.TestCase.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static junit.framework.TestCase.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
@ -36,7 +36,7 @@ import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
||||||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||||
import org.bouncycastle.openpgp.PGPSignature;
|
import org.bouncycastle.openpgp.PGPSignature;
|
||||||
import org.bouncycastle.util.io.Streams;
|
import org.bouncycastle.util.io.Streams;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.pgpainless.PGPainless;
|
import org.pgpainless.PGPainless;
|
||||||
import org.pgpainless.algorithm.KeyFlag;
|
import org.pgpainless.algorithm.KeyFlag;
|
||||||
import org.pgpainless.algorithm.SymmetricKeyAlgorithm;
|
import org.pgpainless.algorithm.SymmetricKeyAlgorithm;
|
||||||
|
|
|
@ -26,11 +26,11 @@ import java.util.Random;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import jdk.nashorn.internal.ir.annotations.Ignore;
|
||||||
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;
|
||||||
import org.bouncycastle.util.io.Streams;
|
import org.bouncycastle.util.io.Streams;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.pgpainless.PGPainless;
|
import org.pgpainless.PGPainless;
|
||||||
import org.pgpainless.key.TestKeys;
|
import org.pgpainless.key.TestKeys;
|
||||||
import org.pgpainless.key.collection.PGPKeyRing;
|
import org.pgpainless.key.collection.PGPKeyRing;
|
||||||
|
|
|
@ -40,7 +40,7 @@ import org.bouncycastle.openpgp.operator.PGPDigestCalculator;
|
||||||
import org.bouncycastle.openpgp.operator.jcajce.JcaPGPContentSignerBuilder;
|
import org.bouncycastle.openpgp.operator.jcajce.JcaPGPContentSignerBuilder;
|
||||||
import org.bouncycastle.openpgp.operator.jcajce.JcaPGPDigestCalculatorProviderBuilder;
|
import org.bouncycastle.openpgp.operator.jcajce.JcaPGPDigestCalculatorProviderBuilder;
|
||||||
import org.bouncycastle.openpgp.operator.jcajce.JcaPGPKeyPair;
|
import org.bouncycastle.openpgp.operator.jcajce.JcaPGPKeyPair;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.pgpainless.provider.ProviderFactory;
|
import org.pgpainless.provider.ProviderFactory;
|
||||||
|
|
||||||
public class BouncycastleExportSubkeys {
|
public class BouncycastleExportSubkeys {
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
*/
|
*/
|
||||||
package org.pgpainless.key;
|
package org.pgpainless.key;
|
||||||
|
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ 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;
|
||||||
import org.bouncycastle.openpgp.operator.bc.BcKeyFingerprintCalculator;
|
import org.bouncycastle.openpgp.operator.bc.BcKeyFingerprintCalculator;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class ImportExportKeyTest {
|
public class ImportExportKeyTest {
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,13 @@
|
||||||
*/
|
*/
|
||||||
package org.pgpainless.key;
|
package org.pgpainless.key;
|
||||||
|
|
||||||
import static junit.framework.TestCase.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static junit.framework.TestCase.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static junit.framework.TestCase.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.pgpainless.algorithm.KeyFlag;
|
import org.pgpainless.algorithm.KeyFlag;
|
||||||
|
|
||||||
public class KeyFlagTest {
|
public class KeyFlagTest {
|
||||||
|
|
|
@ -15,28 +15,30 @@
|
||||||
*/
|
*/
|
||||||
package org.pgpainless.key;
|
package org.pgpainless.key;
|
||||||
|
|
||||||
import static junit.framework.TestCase.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertNotEquals;
|
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
|
|
||||||
import org.bouncycastle.openpgp.PGPPublicKey;
|
import org.bouncycastle.openpgp.PGPPublicKey;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
|
||||||
public class OpenPgpV4FingerprintTest {
|
public class OpenPgpV4FingerprintTest {
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void fpTooShort() {
|
public void fpTooShort() {
|
||||||
String fp = "484f57414c495645"; // Asking Mark
|
String fp = "484f57414c495645"; // Asking Mark
|
||||||
new OpenPgpV4Fingerprint(fp);
|
assertThrows(IllegalArgumentException.class, () -> new OpenPgpV4Fingerprint(fp));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void invalidHexTest() {
|
public void invalidHexTest() {
|
||||||
String fp = "UNFORTUNATELYTHISISNOVALIDHEXADECIMALDOH";
|
String fp = "UNFORTUNATELYTHISISNOVALIDHEXADECIMALDOH";
|
||||||
new OpenPgpV4Fingerprint(fp);
|
assertThrows(IllegalArgumentException.class, () -> new OpenPgpV4Fingerprint(fp));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -88,9 +90,9 @@ public class OpenPgpV4FingerprintTest {
|
||||||
assertEquals(fingerprint, parsed);
|
assertEquals(fingerprint, parsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void testFromUriThrowsIfWrongScheme() throws URISyntaxException {
|
public void testFromUriThrowsIfWrongScheme() throws URISyntaxException {
|
||||||
URI uri = new URI(null, "5448452043414B452049532041204C4945212121", null);
|
URI uri = new URI(null, "5448452043414B452049532041204C4945212121", null);
|
||||||
OpenPgpV4Fingerprint.fromUri(uri);
|
assertThrows(IllegalArgumentException.class, () -> OpenPgpV4Fingerprint.fromUri(uri));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,15 +15,15 @@
|
||||||
*/
|
*/
|
||||||
package org.pgpainless.key;
|
package org.pgpainless.key;
|
||||||
|
|
||||||
import static junit.framework.TestCase.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
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;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.pgpainless.util.TestUtils;
|
import org.pgpainless.util.TestUtils;
|
||||||
|
|
||||||
public class TestKeysTest {
|
public class TestKeysTest {
|
||||||
|
@ -74,8 +74,8 @@ public class TestKeysTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void assertJulietsFingerprintGetKeyIdMatches() {
|
public void assertJulietsFingerprintGetKeyIdMatches() {
|
||||||
assertEquals("calling getKeyId() on juliet's fingerprint must return her key id.",
|
assertEquals(TestKeys.JULIET_KEY_ID, TestKeys.JULIET_FINGERPRINT.getKeyId(),
|
||||||
TestKeys.JULIET_KEY_ID, TestKeys.JULIET_FINGERPRINT.getKeyId());
|
"calling getKeyId() on juliet's fingerprint must return her key id.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -85,8 +85,8 @@ public class TestKeysTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void assertRomeosKeyIdEquals() {
|
public void assertRomeosKeyIdEquals() {
|
||||||
assertEquals("Key ID of Romeo's secret key must match his key id.",
|
assertEquals(TestKeys.ROMEO_KEY_ID, romeoSecRing.getSecretKey().getKeyID(),
|
||||||
TestKeys.ROMEO_KEY_ID, romeoSecRing.getSecretKey().getKeyID());
|
"Key ID of Romeo's secret key must match his key id.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -145,7 +145,7 @@ public class TestKeysTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void assertEmilsFingerprintGetKeyIdMatches() {
|
public void assertEmilsFingerprintGetKeyIdMatches() {
|
||||||
assertEquals("calling getKeyId() on emil's fingerprint must return her key id.",
|
assertEquals(TestKeys.EMIL_KEY_ID, TestKeys.EMIL_FINGERPRINT.getKeyId(),
|
||||||
TestKeys.EMIL_KEY_ID, TestKeys.EMIL_FINGERPRINT.getKeyId());
|
"calling getKeyId() on emil's fingerprint must return her key id.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,29 +15,30 @@
|
||||||
*/
|
*/
|
||||||
package org.pgpainless.key;
|
package org.pgpainless.key;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.pgpainless.key.util.UserId;
|
import org.pgpainless.key.util.UserId;
|
||||||
|
|
||||||
public class UserIdTest {
|
public class UserIdTest {
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void throwForNullName() {
|
public void throwForNullName() {
|
||||||
UserId.withName(null);
|
assertThrows(IllegalArgumentException.class, () -> UserId.withName(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void throwForNullComment() {
|
public void throwForNullComment() {
|
||||||
UserId.withName("foo")
|
assertThrows(IllegalArgumentException.class, () -> UserId.withName("foo")
|
||||||
.withComment(null);
|
.withComment(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void throwForNullEmail() {
|
public void throwForNullEmail() {
|
||||||
UserId.withName("foo")
|
assertThrows(IllegalArgumentException.class, () -> UserId.withName("foo")
|
||||||
.withComment("bar")
|
.withComment("bar")
|
||||||
.withEmail(null);
|
.withEmail(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -24,7 +24,8 @@ import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.bouncycastle.bcpg.ArmoredOutputStream;
|
import org.bouncycastle.bcpg.ArmoredOutputStream;
|
||||||
import org.bouncycastle.openpgp.PGPException;
|
import org.bouncycastle.openpgp.PGPException;
|
||||||
import org.junit.Test;
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
import org.pgpainless.PGPainless;
|
import org.pgpainless.PGPainless;
|
||||||
import org.pgpainless.key.OpenPgpV4Fingerprint;
|
import org.pgpainless.key.OpenPgpV4Fingerprint;
|
||||||
import org.pgpainless.key.collection.PGPKeyRing;
|
import org.pgpainless.key.collection.PGPKeyRing;
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
*/
|
*/
|
||||||
package org.pgpainless.key.generation;
|
package org.pgpainless.key.generation;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -26,7 +26,8 @@ import java.util.Iterator;
|
||||||
|
|
||||||
import org.bouncycastle.bcpg.ArmoredOutputStream;
|
import org.bouncycastle.bcpg.ArmoredOutputStream;
|
||||||
import org.bouncycastle.openpgp.PGPException;
|
import org.bouncycastle.openpgp.PGPException;
|
||||||
import org.junit.Test;
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
import org.pgpainless.PGPainless;
|
import org.pgpainless.PGPainless;
|
||||||
import org.pgpainless.key.collection.PGPKeyRing;
|
import org.pgpainless.key.collection.PGPKeyRing;
|
||||||
import org.pgpainless.key.generation.type.KeyType;
|
import org.pgpainless.key.generation.type.KeyType;
|
||||||
|
|
|
@ -15,14 +15,14 @@
|
||||||
*/
|
*/
|
||||||
package org.pgpainless.key.generation;
|
package org.pgpainless.key.generation;
|
||||||
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.security.InvalidAlgorithmParameterException;
|
import java.security.InvalidAlgorithmParameterException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
|
||||||
import org.bouncycastle.openpgp.PGPException;
|
import org.bouncycastle.openpgp.PGPException;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.pgpainless.PGPainless;
|
import org.pgpainless.PGPainless;
|
||||||
import org.pgpainless.key.generation.type.KeyType;
|
import org.pgpainless.key.generation.type.KeyType;
|
||||||
import org.pgpainless.key.generation.type.length.RsaLength;
|
import org.pgpainless.key.generation.type.length.RsaLength;
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
*/
|
*/
|
||||||
package org.pgpainless.key.modification;
|
package org.pgpainless.key.modification;
|
||||||
|
|
||||||
import static org.junit.Assert.assertNotEquals;
|
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.security.InvalidAlgorithmParameterException;
|
import java.security.InvalidAlgorithmParameterException;
|
||||||
|
@ -29,7 +29,7 @@ import org.bouncycastle.openpgp.PGPPrivateKey;
|
||||||
import org.bouncycastle.openpgp.PGPPublicKey;
|
import org.bouncycastle.openpgp.PGPPublicKey;
|
||||||
import org.bouncycastle.openpgp.PGPSecretKey;
|
import org.bouncycastle.openpgp.PGPSecretKey;
|
||||||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.pgpainless.PGPainless;
|
import org.pgpainless.PGPainless;
|
||||||
import org.pgpainless.algorithm.KeyFlag;
|
import org.pgpainless.algorithm.KeyFlag;
|
||||||
import org.pgpainless.key.TestKeys;
|
import org.pgpainless.key.TestKeys;
|
||||||
|
|
|
@ -15,8 +15,9 @@
|
||||||
*/
|
*/
|
||||||
package org.pgpainless.key.modification;
|
package org.pgpainless.key.modification;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.security.InvalidAlgorithmParameterException;
|
import java.security.InvalidAlgorithmParameterException;
|
||||||
|
@ -26,7 +27,7 @@ import java.util.NoSuchElementException;
|
||||||
|
|
||||||
import org.bouncycastle.openpgp.PGPException;
|
import org.bouncycastle.openpgp.PGPException;
|
||||||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.pgpainless.PGPainless;
|
import org.pgpainless.PGPainless;
|
||||||
import org.pgpainless.key.TestKeys;
|
import org.pgpainless.key.TestKeys;
|
||||||
import org.pgpainless.key.collection.PGPKeyRing;
|
import org.pgpainless.key.collection.PGPKeyRing;
|
||||||
|
@ -65,24 +66,24 @@ public class AddUserIdTest {
|
||||||
assertFalse(userIds.hasNext());
|
assertFalse(userIds.hasNext());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = NoSuchElementException.class)
|
@Test
|
||||||
public void addUserId_NoSuchElementExceptionForMissingKey() throws IOException, PGPException {
|
public void addUserId_NoSuchElementExceptionForMissingKey() throws IOException, PGPException {
|
||||||
PGPSecretKeyRing secretKeys = TestKeys.getCryptieSecretKeyRing();
|
PGPSecretKeyRing secretKeys = TestKeys.getCryptieSecretKeyRing();
|
||||||
PGPainless.modifyKeyRing(secretKeys)
|
assertThrows(NoSuchElementException.class, () -> PGPainless.modifyKeyRing(secretKeys)
|
||||||
.addUserId(0L, TestKeys.CRYPTIE_UID, new UnprotectedKeysProtector());
|
.addUserId(0L, TestKeys.CRYPTIE_UID, new UnprotectedKeysProtector()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = NoSuchElementException.class)
|
@Test
|
||||||
public void deleteUserId_noSuchElementExceptionForMissingUserId() throws IOException, PGPException {
|
public void deleteUserId_noSuchElementExceptionForMissingUserId() throws IOException, PGPException {
|
||||||
PGPSecretKeyRing secretKeys = TestKeys.getCryptieSecretKeyRing();
|
PGPSecretKeyRing secretKeys = TestKeys.getCryptieSecretKeyRing();
|
||||||
PGPainless.modifyKeyRing(secretKeys)
|
assertThrows(NoSuchElementException.class, () -> PGPainless.modifyKeyRing(secretKeys)
|
||||||
.deleteUserId("invalid@user.id", new UnprotectedKeysProtector());
|
.deleteUserId("invalid@user.id", new UnprotectedKeysProtector()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = NoSuchElementException.class)
|
@Test
|
||||||
public void deleteUserId_noSuchElementExceptionForMissingKey() throws IOException, PGPException {
|
public void deleteUserId_noSuchElementExceptionForMissingKey() throws IOException, PGPException {
|
||||||
PGPSecretKeyRing secretKeys = TestKeys.getCryptieSecretKeyRing();
|
PGPSecretKeyRing secretKeys = TestKeys.getCryptieSecretKeyRing();
|
||||||
PGPainless.modifyKeyRing(secretKeys)
|
assertThrows(NoSuchElementException.class, () -> PGPainless.modifyKeyRing(secretKeys)
|
||||||
.deleteUserId(0L, TestKeys.CRYPTIE_UID, new UnprotectedKeysProtector());
|
.deleteUserId(0L, TestKeys.CRYPTIE_UID, new UnprotectedKeysProtector()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,9 @@
|
||||||
*/
|
*/
|
||||||
package org.pgpainless.key.modification;
|
package org.pgpainless.key.modification;
|
||||||
|
|
||||||
import static junit.framework.TestCase.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
@ -33,7 +34,7 @@ import org.bouncycastle.openpgp.operator.PGPDigestCalculatorProvider;
|
||||||
import org.bouncycastle.openpgp.operator.bc.BcPBESecretKeyDecryptorBuilder;
|
import org.bouncycastle.openpgp.operator.bc.BcPBESecretKeyDecryptorBuilder;
|
||||||
import org.bouncycastle.openpgp.operator.bc.BcPGPDigestCalculatorProvider;
|
import org.bouncycastle.openpgp.operator.bc.BcPGPDigestCalculatorProvider;
|
||||||
import org.bouncycastle.util.io.Streams;
|
import org.bouncycastle.util.io.Streams;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.pgpainless.PGPainless;
|
import org.pgpainless.PGPainless;
|
||||||
import org.pgpainless.algorithm.SymmetricKeyAlgorithm;
|
import org.pgpainless.algorithm.SymmetricKeyAlgorithm;
|
||||||
import org.pgpainless.encryption_signing.EncryptionStream;
|
import org.pgpainless.encryption_signing.EncryptionStream;
|
||||||
|
@ -63,25 +64,16 @@ public class ChangeSecretKeyRingPassphraseTest {
|
||||||
assertEquals(KeyRingProtectionSettings.secureDefaultSettings().getEncryptionAlgorithm().getAlgorithmId(),
|
assertEquals(KeyRingProtectionSettings.secureDefaultSettings().getEncryptionAlgorithm().getAlgorithmId(),
|
||||||
changedPassphraseKeyRing.getSecretKeys().getSecretKey().getKeyEncryptionAlgorithm());
|
changedPassphraseKeyRing.getSecretKeys().getSecretKey().getKeyEncryptionAlgorithm());
|
||||||
|
|
||||||
try {
|
assertThrows(PGPException.class, () ->
|
||||||
signDummyMessageWithKeysAndPassphrase(changedPassphraseKeyRing, Passphrase.emptyPassphrase());
|
signDummyMessageWithKeysAndPassphrase(changedPassphraseKeyRing, Passphrase.emptyPassphrase()),
|
||||||
fail("Unlocking secret key ring with empty passphrase MUST fail.");
|
"Unlocking secret key ring with empty passphrase MUST fail.");
|
||||||
} catch (PGPException e) {
|
|
||||||
// yay
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
assertThrows(PGPException.class, () ->
|
||||||
signDummyMessageWithKeysAndPassphrase(changedPassphraseKeyRing, Passphrase.fromPassword("weakPassphrase"));
|
signDummyMessageWithKeysAndPassphrase(changedPassphraseKeyRing, Passphrase.fromPassword("weakPassphrase")),
|
||||||
fail("Unlocking secret key ring with old passphrase MUST fail.");
|
"Unlocking secret key ring with old passphrase MUST fail.");
|
||||||
} catch (PGPException e) {
|
|
||||||
// yay
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
assertDoesNotThrow(() -> signDummyMessageWithKeysAndPassphrase(changedPassphraseKeyRing, Passphrase.fromPassword("1337p455phr453")),
|
||||||
signDummyMessageWithKeysAndPassphrase(changedPassphraseKeyRing, Passphrase.fromPassword("1337p455phr453"));
|
"Unlocking the secret key ring with the new passphrase MUST succeed.");
|
||||||
} catch (PGPException e) {
|
|
||||||
fail("Unlocking the secret key ring with the new passphrase MUST succeed.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -124,19 +116,15 @@ public class ChangeSecretKeyRingPassphraseTest {
|
||||||
extractPrivateKey(primaryKey, Passphrase.fromPassword("weakPassphrase"));
|
extractPrivateKey(primaryKey, Passphrase.fromPassword("weakPassphrase"));
|
||||||
extractPrivateKey(subKey, Passphrase.fromPassword("subKeyPassphrase"));
|
extractPrivateKey(subKey, Passphrase.fromPassword("subKeyPassphrase"));
|
||||||
|
|
||||||
try {
|
final PGPSecretKey finalPrimaryKey = primaryKey;
|
||||||
extractPrivateKey(primaryKey, Passphrase.fromPassword("subKeyPassphrase"));
|
assertThrows(PGPException.class,
|
||||||
fail("Unlocking the primary key with the subkey passphrase must fail.");
|
() -> extractPrivateKey(finalPrimaryKey, Passphrase.fromPassword("subKeyPassphrase")),
|
||||||
} catch (PGPException e) {
|
"Unlocking the primary key with the subkey passphrase must fail.");
|
||||||
// yay
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
final PGPSecretKey finalSubKey = subKey;
|
||||||
extractPrivateKey(subKey, Passphrase.fromPassword("weakPassphrase"));
|
assertThrows(PGPException.class,
|
||||||
fail("Unlocking the subkey with the primary key passphrase must fail.");
|
() -> extractPrivateKey(finalSubKey, Passphrase.fromPassword("weakPassphrase")),
|
||||||
} catch (PGPException e) {
|
"Unlocking the subkey with the primary key passphrase must fail.");
|
||||||
// yay
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -158,20 +146,15 @@ public class ChangeSecretKeyRingPassphraseTest {
|
||||||
extractPrivateKey(primaryKey, Passphrase.emptyPassphrase());
|
extractPrivateKey(primaryKey, Passphrase.emptyPassphrase());
|
||||||
extractPrivateKey(subKey, Passphrase.fromPassword("weakPassphrase"));
|
extractPrivateKey(subKey, Passphrase.fromPassword("weakPassphrase"));
|
||||||
|
|
||||||
try {
|
final PGPSecretKey finalPrimaryKey = primaryKey;
|
||||||
extractPrivateKey(primaryKey, Passphrase.fromPassword("weakPassphrase"));
|
assertThrows(PGPException.class,
|
||||||
fail("Unlocking the unprotected primary key with the old passphrase must fail.");
|
() -> extractPrivateKey(finalPrimaryKey, Passphrase.fromPassword("weakPassphrase")),
|
||||||
} catch (PGPException e) {
|
"Unlocking the unprotected primary key with the old passphrase must fail.");
|
||||||
// yay
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
extractPrivateKey(subKey, Passphrase.emptyPassphrase());
|
|
||||||
fail("Unlocking the still protected subkey with an empty passphrase must fail.");
|
|
||||||
} catch (PGPException e) {
|
|
||||||
// yay
|
|
||||||
}
|
|
||||||
|
|
||||||
|
final PGPSecretKey finalSubKey = subKey;
|
||||||
|
assertThrows(PGPException.class,
|
||||||
|
() -> extractPrivateKey(finalSubKey, Passphrase.emptyPassphrase()),
|
||||||
|
"Unlocking the still protected subkey with an empty passphrase must fail.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -15,12 +15,15 @@
|
||||||
*/
|
*/
|
||||||
package org.pgpainless.key.modification;
|
package org.pgpainless.key.modification;
|
||||||
|
|
||||||
import org.junit.Test;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class KeyRingEditorTest {
|
public class KeyRingEditorTest {
|
||||||
|
|
||||||
@Test(expected = NullPointerException.class)
|
@Test
|
||||||
public void testConstructorThrowsNpeForNull() {
|
public void testConstructorThrowsNpeForNull() {
|
||||||
new KeyRingEditor(null);
|
assertThrows(NullPointerException.class,
|
||||||
|
() -> new KeyRingEditor(null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
*/
|
*/
|
||||||
package org.pgpainless.key.modification;
|
package org.pgpainless.key.modification;
|
||||||
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -24,7 +24,7 @@ import java.util.Iterator;
|
||||||
import org.bouncycastle.openpgp.PGPException;
|
import org.bouncycastle.openpgp.PGPException;
|
||||||
import org.bouncycastle.openpgp.PGPSecretKey;
|
import org.bouncycastle.openpgp.PGPSecretKey;
|
||||||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.pgpainless.PGPainless;
|
import org.pgpainless.PGPainless;
|
||||||
import org.pgpainless.key.OpenPgpV4Fingerprint;
|
import org.pgpainless.key.OpenPgpV4Fingerprint;
|
||||||
import org.pgpainless.key.TestKeys;
|
import org.pgpainless.key.TestKeys;
|
||||||
|
|
|
@ -15,13 +15,13 @@
|
||||||
*/
|
*/
|
||||||
package org.pgpainless.key.protection;
|
package org.pgpainless.key.protection;
|
||||||
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.bouncycastle.openpgp.PGPException;
|
import org.bouncycastle.openpgp.PGPException;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.pgpainless.key.TestKeys;
|
import org.pgpainless.key.TestKeys;
|
||||||
import org.pgpainless.key.protection.passphrase_provider.SecretKeyPassphraseProvider;
|
import org.pgpainless.key.protection.passphrase_provider.SecretKeyPassphraseProvider;
|
||||||
import org.pgpainless.util.Passphrase;
|
import org.pgpainless.util.Passphrase;
|
||||||
|
|
|
@ -15,12 +15,12 @@
|
||||||
*/
|
*/
|
||||||
package org.pgpainless.key.protection;
|
package org.pgpainless.key.protection;
|
||||||
|
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.pgpainless.util.Passphrase;
|
import org.pgpainless.util.Passphrase;
|
||||||
|
|
||||||
public class PassphraseTest {
|
public class PassphraseTest {
|
||||||
|
@ -35,11 +35,6 @@ public class PassphraseTest {
|
||||||
passphrase.clear();
|
passphrase.clear();
|
||||||
|
|
||||||
assertFalse(passphrase.isValid());
|
assertFalse(passphrase.isValid());
|
||||||
try {
|
assertThrows(IllegalStateException.class, passphrase::getChars);
|
||||||
passphrase.getChars();
|
|
||||||
fail();
|
|
||||||
} catch (IllegalStateException e) {
|
|
||||||
// expected
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,9 +15,9 @@
|
||||||
*/
|
*/
|
||||||
package org.pgpainless.key.protection;
|
package org.pgpainless.key.protection;
|
||||||
|
|
||||||
import static junit.framework.TestCase.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class UnprotectedKeysProtectorTest {
|
public class UnprotectedKeysProtectorTest {
|
||||||
|
|
||||||
|
|
|
@ -15,15 +15,15 @@
|
||||||
*/
|
*/
|
||||||
package org.pgpainless.key.selection.keyring;
|
package org.pgpainless.key.selection.keyring;
|
||||||
|
|
||||||
import static junit.framework.TestCase.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static junit.framework.TestCase.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.bouncycastle.openpgp.PGPException;
|
import org.bouncycastle.openpgp.PGPException;
|
||||||
import org.bouncycastle.openpgp.PGPPublicKey;
|
import org.bouncycastle.openpgp.PGPPublicKey;
|
||||||
import org.bouncycastle.openpgp.PGPSecretKey;
|
import org.bouncycastle.openpgp.PGPSecretKey;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.pgpainless.key.TestKeys;
|
import org.pgpainless.key.TestKeys;
|
||||||
import org.pgpainless.key.selection.keyring.impl.Email;
|
import org.pgpainless.key.selection.keyring.impl.Email;
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
*/
|
*/
|
||||||
package org.pgpainless.key.selection.keyring;
|
package org.pgpainless.key.selection.keyring;
|
||||||
|
|
||||||
import static junit.framework.TestCase.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static junit.framework.TestCase.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -27,7 +27,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||||
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;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.pgpainless.key.TestKeys;
|
import org.pgpainless.key.TestKeys;
|
||||||
import org.pgpainless.key.selection.keyring.impl.Whitelist;
|
import org.pgpainless.key.selection.keyring.impl.Whitelist;
|
||||||
|
|
||||||
|
|
|
@ -15,14 +15,14 @@
|
||||||
*/
|
*/
|
||||||
package org.pgpainless.key.selection.keyring;
|
package org.pgpainless.key.selection.keyring;
|
||||||
|
|
||||||
import static junit.framework.TestCase.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
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;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.pgpainless.key.TestKeys;
|
import org.pgpainless.key.TestKeys;
|
||||||
import org.pgpainless.key.selection.keyring.impl.Wildcard;
|
import org.pgpainless.key.selection.keyring.impl.Wildcard;
|
||||||
|
|
||||||
|
|
|
@ -15,15 +15,15 @@
|
||||||
*/
|
*/
|
||||||
package org.pgpainless.key.selection.keyring;
|
package org.pgpainless.key.selection.keyring;
|
||||||
|
|
||||||
import static junit.framework.TestCase.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static junit.framework.TestCase.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
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;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.pgpainless.key.TestKeys;
|
import org.pgpainless.key.TestKeys;
|
||||||
import org.pgpainless.key.selection.keyring.impl.XMPP;
|
import org.pgpainless.key.selection.keyring.impl.XMPP;
|
||||||
|
|
||||||
|
|
|
@ -15,11 +15,11 @@
|
||||||
*/
|
*/
|
||||||
package org.pgpainless.provider;
|
package org.pgpainless.provider;
|
||||||
|
|
||||||
import static junit.framework.TestCase.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
import java.security.Provider;
|
import java.security.Provider;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class ProviderFactoryTest {
|
public class ProviderFactoryTest {
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
*/
|
*/
|
||||||
package org.pgpainless.symmetric_encryption;
|
package org.pgpainless.symmetric_encryption;
|
||||||
|
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -24,7 +24,7 @@ import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.bouncycastle.bcpg.ArmoredOutputStream;
|
import org.bouncycastle.bcpg.ArmoredOutputStream;
|
||||||
import org.bouncycastle.openpgp.PGPException;
|
import org.bouncycastle.openpgp.PGPException;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.pgpainless.PGPainless;
|
import org.pgpainless.PGPainless;
|
||||||
import org.pgpainless.algorithm.SymmetricKeyAlgorithm;
|
import org.pgpainless.algorithm.SymmetricKeyAlgorithm;
|
||||||
import org.pgpainless.util.Passphrase;
|
import org.pgpainless.util.Passphrase;
|
||||||
|
|
|
@ -15,8 +15,10 @@
|
||||||
*/
|
*/
|
||||||
package org.pgpainless.util;
|
package org.pgpainless.util;
|
||||||
|
|
||||||
import static junit.framework.TestCase.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.security.InvalidAlgorithmParameterException;
|
import java.security.InvalidAlgorithmParameterException;
|
||||||
|
@ -26,7 +28,6 @@ import java.util.Iterator;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
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,7 +35,7 @@ import org.bouncycastle.openpgp.PGPPublicKeyRingCollection;
|
||||||
import org.bouncycastle.openpgp.PGPSecretKey;
|
import org.bouncycastle.openpgp.PGPSecretKey;
|
||||||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||||
import org.bouncycastle.openpgp.PGPSecretKeyRingCollection;
|
import org.bouncycastle.openpgp.PGPSecretKeyRingCollection;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.pgpainless.PGPainless;
|
import org.pgpainless.PGPainless;
|
||||||
import org.pgpainless.key.collection.PGPKeyRing;
|
import org.pgpainless.key.collection.PGPKeyRing;
|
||||||
import org.pgpainless.key.generation.KeySpec;
|
import org.pgpainless.key.generation.KeySpec;
|
||||||
|
@ -119,15 +120,15 @@ public class BCUtilTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TestCase.assertNotNull(subKey);
|
assertNotNull(subKey);
|
||||||
|
|
||||||
PGPSecretKeyRing alice_mallory = PGPSecretKeyRing.insertSecretKey(alice.getSecretKeys(), subKey);
|
PGPSecretKeyRing alice_mallory = PGPSecretKeyRing.insertSecretKey(alice.getSecretKeys(), subKey);
|
||||||
|
|
||||||
// Check, if alice_mallory contains mallory's key
|
// Check, if alice_mallory contains mallory's key
|
||||||
TestCase.assertNotNull(alice_mallory.getSecretKey(subKey.getKeyID()));
|
assertNotNull(alice_mallory.getSecretKey(subKey.getKeyID()));
|
||||||
|
|
||||||
PGPSecretKeyRing cleaned = BCUtil.removeUnassociatedKeysFromKeyRing(alice_mallory, alice.getPublicKeys().getPublicKey());
|
PGPSecretKeyRing cleaned = BCUtil.removeUnassociatedKeysFromKeyRing(alice_mallory, alice.getPublicKeys().getPublicKey());
|
||||||
TestCase.assertNull(cleaned.getSecretKey(subKey.getKeyID()));
|
assertNull(cleaned.getSecretKey(subKey.getKeyID()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -15,13 +15,13 @@
|
||||||
*/
|
*/
|
||||||
package org.pgpainless.util;
|
package org.pgpainless.util;
|
||||||
|
|
||||||
import static junit.framework.TestCase.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static junit.framework.TestCase.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static junit.framework.TestCase.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||||
import static junit.framework.TestCase.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static junit.framework.TestCase.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
import static junit.framework.TestCase.fail;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import static org.junit.Assert.assertNotEquals;
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -30,7 +30,7 @@ import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class MultiMapTest {
|
public class MultiMapTest {
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue