Add test for SubkeyIdentifier.isPrimaryKey()

This commit is contained in:
Paul Schaub 2023-09-08 15:03:49 +02:00
parent 9ee0f09b8d
commit 85e2fe956a
Signed by: vanitasvitae
GPG Key ID: 62BEE9264BF17311
1 changed files with 11 additions and 0 deletions

View File

@ -5,8 +5,10 @@
package org.pgpainless.key;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.util.NoSuchElementException;
@ -102,6 +104,15 @@ public class SubkeyIdentifierTest {
assertNotEquals(id1, null);
}
@Test
public void testIsPrimaryKey() {
SubkeyIdentifier primaryKey = new SubkeyIdentifier(PRIMARY_FP);
assertTrue(primaryKey.isPrimaryKey());
SubkeyIdentifier subKey = new SubkeyIdentifier(PRIMARY_FP, SUBKEY_FP);
assertFalse(subKey.isPrimaryKey());
}
@Test
public void nonExistentSubkeyThrowsNoSuchElementException() {
assertThrows(NoSuchElementException.class, () -> new SubkeyIdentifier(CERT, 123));