mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-05 03:55:58 +01:00
Add regression test for #351
This commit is contained in:
parent
05ae631a12
commit
8e768636c8
1 changed files with 25 additions and 0 deletions
|
@ -6,16 +6,21 @@ 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.assertThrows;
|
||||
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;
|
||||
import sop.exception.SOPGPException;
|
||||
|
||||
|
@ -74,4 +79,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