mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-09-09 18:29:39 +02:00
Improve GnuPGDummyKeyUtilTest
This commit is contained in:
parent
4e5eff6113
commit
5b39aea421
1 changed files with 16 additions and 0 deletions
|
@ -9,10 +9,12 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.bouncycastle.bcpg.KeyIdentifier;
|
||||||
import org.bouncycastle.bcpg.S2K;
|
import org.bouncycastle.bcpg.S2K;
|
||||||
import org.bouncycastle.bcpg.SecretKeyPacket;
|
import org.bouncycastle.bcpg.SecretKeyPacket;
|
||||||
import org.bouncycastle.openpgp.PGPSecretKey;
|
import org.bouncycastle.openpgp.PGPSecretKey;
|
||||||
|
@ -232,6 +234,20 @@ public class GnuPGDummyKeyUtilTest {
|
||||||
assertArrayEquals(expected.getPGPSecretKeyRing().getEncoded(), onCard.getEncoded());
|
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
|
@Test
|
||||||
public void testRemoveAllKeys() throws IOException {
|
public void testRemoveAllKeys() throws IOException {
|
||||||
OpenPGPKeyReader reader = PGPainless.getInstance().readKey();
|
OpenPGPKeyReader reader = PGPainless.getInstance().readKey();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue