mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-01-09 19:57:57 +01:00
Test if userId is present
This commit is contained in:
parent
11e7bc69fc
commit
2f85c9a8d0
1 changed files with 10 additions and 2 deletions
|
@ -1,17 +1,19 @@
|
||||||
package org.pgpainless.key.generation;
|
package org.pgpainless.key.generation;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.security.InvalidAlgorithmParameterException;
|
import java.security.InvalidAlgorithmParameterException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
import org.bouncycastle.bcpg.ArmoredOutputStream;
|
import org.bouncycastle.bcpg.ArmoredOutputStream;
|
||||||
import org.bouncycastle.openpgp.PGPException;
|
import org.bouncycastle.openpgp.PGPException;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.pgpainless.PGPainless;
|
import org.pgpainless.PGPainless;
|
||||||
import org.pgpainless.key.collection.PGPKeyRing;
|
import org.pgpainless.key.collection.PGPKeyRing;
|
||||||
import org.pgpainless.key.generation.type.KeyType;
|
|
||||||
import org.pgpainless.key.generation.type.RSA_SIGN;
|
import org.pgpainless.key.generation.type.RSA_SIGN;
|
||||||
import org.pgpainless.key.generation.type.length.RsaLength;
|
import org.pgpainless.key.generation.type.length.RsaLength;
|
||||||
|
|
||||||
|
@ -28,11 +30,17 @@ public class GenerateKeyWithAdditionalUserIdTest {
|
||||||
.withoutPassphrase()
|
.withoutPassphrase()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
Iterator<String> userIds = keyRing.getPublicKeys().getPublicKey().getUserIDs();
|
||||||
|
assertEquals("primary@user.id", userIds.next());
|
||||||
|
assertEquals("additional@user.id", userIds.next());
|
||||||
|
assertFalse(userIds.hasNext());
|
||||||
|
|
||||||
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
|
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
|
||||||
ArmoredOutputStream armor = new ArmoredOutputStream(byteOut);
|
ArmoredOutputStream armor = new ArmoredOutputStream(byteOut);
|
||||||
keyRing.getSecretKeys().encode(armor);
|
keyRing.getSecretKeys().encode(armor);
|
||||||
armor.close();
|
armor.close();
|
||||||
|
|
||||||
|
// echo this | gpg --list-packets
|
||||||
System.out.println(byteOut.toString("UTF-8"));
|
System.out.println(byteOut.toString("UTF-8"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue