diff options
author | Harsh Shandilya <me@msfjarvis.dev> | 2021-02-15 13:05:09 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-15 13:05:09 +0530 |
commit | 051d455c9f68d7edbc75abbc8d9293dd34d1d250 (patch) | |
tree | 2354ee3cf44c1bf09c97a3cabee3b37b0f717ef3 /app/src/test/java/dev | |
parent | 7fbe4be71143e0d57a14d19f66496213d8248b1d (diff) |
Add tests for GPG identifier parsing (#1319)
Diffstat (limited to 'app/src/test/java/dev')
-rw-r--r-- | app/src/test/java/dev/msfjarvis/aps/util/crypto/GpgIdentifierTest.kt | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/app/src/test/java/dev/msfjarvis/aps/util/crypto/GpgIdentifierTest.kt b/app/src/test/java/dev/msfjarvis/aps/util/crypto/GpgIdentifierTest.kt new file mode 100644 index 00000000..efb08f7b --- /dev/null +++ b/app/src/test/java/dev/msfjarvis/aps/util/crypto/GpgIdentifierTest.kt @@ -0,0 +1,38 @@ +package dev.msfjarvis.aps.util.crypto + +import kotlin.test.Ignore +import kotlin.test.assertNotNull +import kotlin.test.assertTrue +import kotlin.test.Test + +class GpgIdentifierTest { + + @Test + fun `parses hexadecimal key id without leading 0x`() { + val identifier = GpgIdentifier.fromString("79E8208280490C77") + assertNotNull(identifier) + assertTrue { identifier is GpgIdentifier.KeyId } + } + + @Test + fun `parses hexadecimal key id`() { + val identifier = GpgIdentifier.fromString("0x79E8208280490C77") + assertNotNull(identifier) + assertTrue { identifier is GpgIdentifier.KeyId } + } + + @Test + fun `parses email as user id`() { + val identifier = GpgIdentifier.fromString("aps@msfjarvis.dev") + assertNotNull(identifier) + assertTrue { identifier is GpgIdentifier.UserId } + } + + @Test + @Ignore("OpenKeychain can't yet handle these so we don't either") + fun `parses non-email user id`() { + val identifier = GpgIdentifier.fromString("john.doe") + assertNotNull(identifier) + assertTrue { identifier is GpgIdentifier.UserId } + } +} |