mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-09-14 04:39:39 +02:00
Add toUri/fromUri methods to OpenPgpV4Fingerprint
This commit is contained in:
parent
6c449b86af
commit
46af22cc50
2 changed files with 38 additions and 0 deletions
|
@ -19,6 +19,8 @@ import static junit.framework.TestCase.assertEquals;
|
|||
import static org.junit.Assert.assertNotEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import org.bouncycastle.openpgp.PGPPublicKey;
|
||||
import org.junit.Test;
|
||||
|
@ -74,4 +76,21 @@ public class OpenPgpV4FingerprintTest {
|
|||
OpenPgpV4Fingerprint fingerprint = new OpenPgpV4Fingerprint(key);
|
||||
assertEquals(keyId, fingerprint.getKeyId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToUri() {
|
||||
OpenPgpV4Fingerprint fingerprint = new OpenPgpV4Fingerprint("5448452043414B452049532041204C4945212121");
|
||||
|
||||
URI uri = fingerprint.toUri();
|
||||
assertEquals("openpgp4fpr:5448452043414B452049532041204C4945212121", uri.toString());
|
||||
|
||||
OpenPgpV4Fingerprint parsed = OpenPgpV4Fingerprint.fromUri(uri);
|
||||
assertEquals(fingerprint, parsed);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testFromUriThrowsIfWrongScheme() throws URISyntaxException {
|
||||
URI uri = new URI(null, "5448452043414B452049532041204C4945212121", null);
|
||||
OpenPgpV4Fingerprint.fromUri(uri);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue