mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-09-10 18:59:39 +02:00
Migrate some tests to new API
This commit is contained in:
parent
4260ed7969
commit
6273f93d59
2 changed files with 29 additions and 36 deletions
|
@ -12,8 +12,8 @@ import java.io.ByteArrayOutputStream;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
||||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.bouncycastle.openpgp.api.OpenPGPCertificate;
|
||||
import org.bouncycastle.openpgp.api.OpenPGPKey;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.algorithm.KeyFlag;
|
||||
|
@ -295,13 +295,13 @@ public class RoundTripEncryptDecryptCmdTest extends CLITest {
|
|||
|
||||
@Test
|
||||
public void testEncryptWithIncapableCert() throws IOException {
|
||||
PGPSecretKeyRing secretKeys = PGPainless.buildKeyRing()
|
||||
PGPainless api = PGPainless.getInstance();
|
||||
OpenPGPKey key = api.buildKey()
|
||||
.addUserId("No Crypt <no@crypt.key>")
|
||||
.setPrimaryKey(KeySpec.getBuilder(KeyType.EDDSA_LEGACY(EdDSALegacyCurve._Ed25519),
|
||||
KeyFlag.CERTIFY_OTHER, KeyFlag.SIGN_DATA))
|
||||
.build()
|
||||
.getPGPSecretKeyRing();
|
||||
PGPPublicKeyRing cert = PGPainless.extractCertificate(secretKeys);
|
||||
.build();
|
||||
OpenPGPCertificate cert = key.toCertificate();
|
||||
File certFile = writeFile("cert.pgp", cert.getEncoded());
|
||||
|
||||
pipeStringToStdin("Hello, World!\n");
|
||||
|
@ -315,15 +315,15 @@ public class RoundTripEncryptDecryptCmdTest extends CLITest {
|
|||
@Test
|
||||
public void testSignWithIncapableKey()
|
||||
throws IOException {
|
||||
PGPSecretKeyRing secretKeys = PGPainless.buildKeyRing()
|
||||
PGPainless api = PGPainless.getInstance();
|
||||
OpenPGPKey key = api.buildKey()
|
||||
.addUserId("Cannot Sign <cannot@sign.key>")
|
||||
.setPrimaryKey(KeySpec.getBuilder(KeyType.EDDSA_LEGACY(EdDSALegacyCurve._Ed25519), KeyFlag.CERTIFY_OTHER))
|
||||
.addSubkey(KeySpec.getBuilder(
|
||||
KeyType.XDH_LEGACY(XDHLegacySpec._X25519), KeyFlag.ENCRYPT_COMMS, KeyFlag.ENCRYPT_STORAGE))
|
||||
.build()
|
||||
.getPGPSecretKeyRing();
|
||||
File keyFile = writeFile("key.pgp", secretKeys.getEncoded());
|
||||
File certFile = writeFile("cert.pgp", PGPainless.extractCertificate(secretKeys).getEncoded());
|
||||
.build();
|
||||
File keyFile = writeFile("key.pgp", key.getEncoded());
|
||||
File certFile = writeFile("cert.pgp", key.toCertificate().getEncoded());
|
||||
|
||||
pipeStringToStdin("Hello, World!\n");
|
||||
ByteArrayOutputStream out = pipeStdoutToStream();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue