From 051d455c9f68d7edbc75abbc8d9293dd34d1d250 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Mon, 15 Feb 2021 13:05:09 +0530 Subject: Add tests for GPG identifier parsing (#1319) --- .../msfjarvis/aps/util/crypto/GpgIdentifierTest.kt | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 app/src/test/java/dev/msfjarvis/aps/util/crypto/GpgIdentifierTest.kt (limited to 'app/src/test') 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 } + } +} -- cgit v1.2.3