mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-09-14 04:39:39 +02:00
Add OpenPgpFingerprint.parse(String)
This commit is contained in:
parent
8f473b513f
commit
6b9b956c2c
3 changed files with 39 additions and 0 deletions
|
@ -7,6 +7,7 @@ package org.pgpainless.key;
|
|||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
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.net.URI;
|
||||
|
@ -91,4 +92,14 @@ public class OpenPgpV4FingerprintTest {
|
|||
OpenPgpV4Fingerprint fingerprint = new OpenPgpV4Fingerprint(prettyPrint);
|
||||
assertEquals(prettyPrint, fingerprint.prettyPrint());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParse() {
|
||||
String prettyPrint = "C94B 884B 9A56 7B1C FB23 6999 7DC5 BDAC BBDF BF87";
|
||||
OpenPgpFingerprint parsed = OpenPgpFingerprint.parse(prettyPrint);
|
||||
|
||||
assertTrue(parsed instanceof OpenPgpV4Fingerprint);
|
||||
OpenPgpV4Fingerprint v4fp = (OpenPgpV4Fingerprint) parsed;
|
||||
assertEquals(prettyPrint, v4fp.prettyPrint());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ package org.pgpainless.key;
|
|||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class OpenPgpV5FingerprintTest {
|
||||
|
||||
|
@ -22,4 +23,14 @@ public class OpenPgpV5FingerprintTest {
|
|||
long id = fingerprint.getKeyId();
|
||||
assertEquals("76543210abcdefab", Long.toHexString(id));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParse() {
|
||||
String prettyPrint = "76543210 ABCDEFAB 01AB23CD 1C0FFEE1 1EEFF0C1 DC32BA10 BAFEDCBA 01234567";
|
||||
OpenPgpFingerprint parsed = OpenPgpFingerprint.parse(prettyPrint);
|
||||
|
||||
assertTrue(parsed instanceof OpenPgpV5Fingerprint);
|
||||
OpenPgpV5Fingerprint v5fp = (OpenPgpV5Fingerprint) parsed;
|
||||
assertEquals(prettyPrint, v5fp.prettyPrint());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue