1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2025-09-09 18:29:39 +02:00

Improve GnuPGDummyKeyUtilTest

This commit is contained in:
Paul Schaub 2025-05-19 14:22:52 +02:00
parent 4e5eff6113
commit 5b39aea421
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -9,10 +9,12 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import org.bouncycastle.bcpg.KeyIdentifier;
import org.bouncycastle.bcpg.S2K;
import org.bouncycastle.bcpg.SecretKeyPacket;
import org.bouncycastle.openpgp.PGPSecretKey;
@ -232,6 +234,20 @@ public class GnuPGDummyKeyUtilTest {
assertArrayEquals(expected.getPGPSecretKeyRing().getEncoded(), onCard.getEncoded());
}
@Test
public void testMoveSelectedKeyToCard() throws IOException {
OpenPGPKeyReader reader = PGPainless.getInstance().readKey();
OpenPGPKey secretKeys = reader.parseKey(FULL_KEY);
OpenPGPKey expected = reader.parseKey(SIGNATURE_KEY_ON_CARD);
PGPSecretKeyRing onCard = GnuPGDummyKeyUtil.modify(secretKeys)
.divertPrivateKeysToCard(GnuPGDummyKeyUtil.KeyFilter.selected(
Arrays.asList(new KeyIdentifier(signatureKeyId)))
, cardSerial);
assertArrayEquals(expected.getPGPSecretKeyRing().getEncoded(), onCard.getEncoded());
}
@Test
public void testRemoveAllKeys() throws IOException {
OpenPGPKeyReader reader = PGPainless.getInstance().readKey();