mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2025-09-09 18:29:48 +02:00
Compare commits
No commits in common. "589dcacd917189140195b322d22110ff46ebad04" and "7c4b4a4ddb6e3a13c3519879e539b8dd92042414" have entirely different histories.
589dcacd91
...
7c4b4a4ddb
2 changed files with 0 additions and 111 deletions
|
@ -9,7 +9,6 @@ import org.junit.jupiter.api.condition.EnabledIf;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.Arguments;
|
import org.junit.jupiter.params.provider.Arguments;
|
||||||
import org.junit.jupiter.params.provider.MethodSource;
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
import sop.Profile;
|
|
||||||
import sop.SOP;
|
import sop.SOP;
|
||||||
import sop.exception.SOPGPException;
|
import sop.exception.SOPGPException;
|
||||||
import sop.testsuite.JUtils;
|
import sop.testsuite.JUtils;
|
||||||
|
@ -17,11 +16,9 @@ import sop.testsuite.TestData;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
|
||||||
|
|
||||||
@EnabledIf("sop.testsuite.operation.AbstractSOPTest#hasBackends")
|
@EnabledIf("sop.testsuite.operation.AbstractSOPTest#hasBackends")
|
||||||
public class GenerateKeyTest extends AbstractSOPTest {
|
public class GenerateKeyTest extends AbstractSOPTest {
|
||||||
|
@ -121,30 +118,4 @@ public class GenerateKeyTest extends AbstractSOPTest {
|
||||||
sop.encrypt().withCert(signingOnlyCert)
|
sop.encrypt().withCert(signingOnlyCert)
|
||||||
.plaintext(TestData.PLAINTEXT.getBytes(StandardCharsets.UTF_8)));
|
.plaintext(TestData.PLAINTEXT.getBytes(StandardCharsets.UTF_8)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
|
||||||
@MethodSource("provideInstances")
|
|
||||||
public void generateKeyWithSupportedProfiles(SOP sop) throws IOException {
|
|
||||||
List<Profile> profiles = sop.listProfiles()
|
|
||||||
.generateKey();
|
|
||||||
|
|
||||||
for (Profile profile : profiles) {
|
|
||||||
generateKeyWithProfile(sop, profile.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void generateKeyWithProfile(SOP sop, String profile) throws IOException {
|
|
||||||
byte[] key;
|
|
||||||
try {
|
|
||||||
key = sop.generateKey()
|
|
||||||
.profile(profile)
|
|
||||||
.userId("Alice <alice@pgpainless.org>")
|
|
||||||
.generate()
|
|
||||||
.getBytes();
|
|
||||||
} catch (SOPGPException.UnsupportedProfile e) {
|
|
||||||
key = null;
|
|
||||||
}
|
|
||||||
assumeTrue(key != null, "'generate-key' does not support profile '" + profile + "'.");
|
|
||||||
JUtils.assertArrayStartsWith(key, TestData.BEGIN_PGP_PRIVATE_KEY_BLOCK);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
package sop.testsuite.operation;
|
package sop.testsuite.operation;
|
||||||
|
|
||||||
import kotlin.collections.ArraysKt;
|
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.Arguments;
|
import org.junit.jupiter.params.provider.Arguments;
|
||||||
import org.junit.jupiter.params.provider.MethodSource;
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
|
@ -44,52 +43,6 @@ public class MergeCertsTest extends AbstractSOPTest {
|
||||||
assertArrayEquals(cert, merged);
|
assertArrayEquals(cert, merged);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
|
||||||
@MethodSource("provideInstances")
|
|
||||||
public void testMergeWithItselfArmored(SOP sop) throws IOException {
|
|
||||||
byte[] key = sop.generateKey()
|
|
||||||
.noArmor()
|
|
||||||
.userId("Alice <alice@pgpainless.org>")
|
|
||||||
.generate()
|
|
||||||
.getBytes();
|
|
||||||
|
|
||||||
byte[] cert = sop.extractCert()
|
|
||||||
.key(key)
|
|
||||||
.getBytes();
|
|
||||||
|
|
||||||
byte[] merged = sop.mergeCerts()
|
|
||||||
.updates(cert)
|
|
||||||
.baseCertificates(cert)
|
|
||||||
.getBytes();
|
|
||||||
|
|
||||||
assertArrayEquals(cert, merged);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ParameterizedTest
|
|
||||||
@MethodSource("provideInstances")
|
|
||||||
public void testMergeWithItselfViaBase(SOP sop) throws IOException {
|
|
||||||
byte[] key = sop.generateKey()
|
|
||||||
.noArmor()
|
|
||||||
.userId("Alice <alice@pgpainless.org>")
|
|
||||||
.generate()
|
|
||||||
.getBytes();
|
|
||||||
|
|
||||||
byte[] cert = sop.extractCert()
|
|
||||||
.noArmor()
|
|
||||||
.key(key)
|
|
||||||
.getBytes();
|
|
||||||
|
|
||||||
byte[] certs = ArraysKt.plus(cert, cert);
|
|
||||||
|
|
||||||
byte[] merged = sop.mergeCerts()
|
|
||||||
.noArmor()
|
|
||||||
.updates(cert)
|
|
||||||
.baseCertificates(certs)
|
|
||||||
.getBytes();
|
|
||||||
|
|
||||||
assertArrayEquals(cert, merged);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@MethodSource("provideInstances")
|
@MethodSource("provideInstances")
|
||||||
public void testApplyBaseToUpdate(SOP sop) throws IOException {
|
public void testApplyBaseToUpdate(SOP sop) throws IOException {
|
||||||
|
@ -145,39 +98,4 @@ public class MergeCertsTest extends AbstractSOPTest {
|
||||||
|
|
||||||
assertArrayEquals(update, merged);
|
assertArrayEquals(update, merged);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
|
||||||
@MethodSource("provideInstances")
|
|
||||||
public void testApplyUpdateToMissingBaseDoesNothing(SOP sop) throws IOException {
|
|
||||||
byte[] aliceKey = sop.generateKey()
|
|
||||||
.noArmor()
|
|
||||||
.userId("Alice <alice@pgpainless.org>")
|
|
||||||
.generate()
|
|
||||||
.getBytes();
|
|
||||||
|
|
||||||
byte[] aliceCert = sop.extractCert()
|
|
||||||
.noArmor()
|
|
||||||
.key(aliceKey)
|
|
||||||
.getBytes();
|
|
||||||
|
|
||||||
byte[] bobKey = sop.generateKey()
|
|
||||||
.noArmor()
|
|
||||||
.userId("Bob <bob@pgpainless.org>")
|
|
||||||
.generate()
|
|
||||||
.getBytes();
|
|
||||||
|
|
||||||
byte[] bobCert = sop.extractCert()
|
|
||||||
.noArmor()
|
|
||||||
.key(bobKey)
|
|
||||||
.getBytes();
|
|
||||||
|
|
||||||
byte[] merged = sop.mergeCerts()
|
|
||||||
.noArmor()
|
|
||||||
.updates(bobCert)
|
|
||||||
.baseCertificates(aliceCert)
|
|
||||||
.getBytes();
|
|
||||||
|
|
||||||
assertArrayEquals(aliceCert, merged);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue