mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-12-22 19:08:00 +01:00
Add regression test for #351
This commit is contained in:
parent
3b2d0795f7
commit
ab6b6ca2e7
1 changed files with 25 additions and 0 deletions
|
@ -6,15 +6,20 @@ package org.pgpainless.sop;
|
|||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.bouncycastle.openpgp.PGPException;
|
||||
import org.bouncycastle.openpgp.PGPSecretKey;
|
||||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.key.info.KeyRingInfo;
|
||||
import org.pgpainless.key.protection.UnlockSecretKey;
|
||||
import org.pgpainless.util.Passphrase;
|
||||
import sop.SOP;
|
||||
|
||||
public class GenerateKeyTest {
|
||||
|
@ -67,4 +72,24 @@ public class GenerateKeyTest {
|
|||
|
||||
assertFalse(new String(bytes).startsWith("-----BEGIN PGP PRIVATE KEY BLOCK-----"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void protectedMultiUserIdKey() throws IOException, PGPException {
|
||||
byte[] bytes = sop.generateKey()
|
||||
.userId("Alice")
|
||||
.userId("Bob")
|
||||
.withKeyPassword("sw0rdf1sh")
|
||||
.generate()
|
||||
.getBytes();
|
||||
|
||||
PGPSecretKeyRing secretKey = PGPainless.readKeyRing().secretKeyRing(bytes);
|
||||
KeyRingInfo info = PGPainless.inspectKeyRing(secretKey);
|
||||
|
||||
assertTrue(info.getUserIds().contains("Alice"));
|
||||
assertTrue(info.getUserIds().contains("Bob"));
|
||||
|
||||
for (PGPSecretKey key : secretKey) {
|
||||
assertNotNull(UnlockSecretKey.unlockSecretKey(key, Passphrase.fromPassword("sw0rdf1sh")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue