aboutsummaryrefslogtreecommitdiff
path: root/crypto-pgpainless/src/test/kotlin
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2022-02-21 20:12:19 +0530
committerGitHub <noreply@github.com>2022-02-21 20:12:19 +0530
commitbbbcc76d6562531502ffc4db7831ab34acddbacf (patch)
tree93761e9857c9a675dc0feee3cd01a0409b4d0a5f /crypto-pgpainless/src/test/kotlin
parente343c66d8b15037c5b73a32dd71f5f6fee26a120 (diff)
Add failing test for multiple identities (#1741)
Diffstat (limited to 'crypto-pgpainless/src/test/kotlin')
-rw-r--r--crypto-pgpainless/src/test/kotlin/dev/msfjarvis/aps/crypto/KeyUtilsTest.kt22
-rw-r--r--crypto-pgpainless/src/test/kotlin/dev/msfjarvis/aps/crypto/TestUtils.kt5
2 files changed, 27 insertions, 0 deletions
diff --git a/crypto-pgpainless/src/test/kotlin/dev/msfjarvis/aps/crypto/KeyUtilsTest.kt b/crypto-pgpainless/src/test/kotlin/dev/msfjarvis/aps/crypto/KeyUtilsTest.kt
new file mode 100644
index 00000000..80c14254
--- /dev/null
+++ b/crypto-pgpainless/src/test/kotlin/dev/msfjarvis/aps/crypto/KeyUtilsTest.kt
@@ -0,0 +1,22 @@
+package dev.msfjarvis.aps.crypto
+
+import dev.msfjarvis.aps.crypto.KeyUtils.tryGetId
+import dev.msfjarvis.aps.crypto.KeyUtils.tryParseKeyring
+import dev.msfjarvis.aps.crypto.TestUtils.getArmoredPrivateKeyWithMultipleIdentities
+import kotlin.test.Test
+import kotlin.test.assertIs
+import kotlin.test.assertNotNull
+import org.bouncycastle.openpgp.PGPSecretKeyRing
+
+class KeyUtilsTest {
+ @Test
+ fun `parse GPG key with multiple identities`() {
+ val key = PGPKey(getArmoredPrivateKeyWithMultipleIdentities())
+ val keyring = tryParseKeyring(key)
+ assertNotNull(keyring)
+ assertIs<PGPSecretKeyRing>(keyring)
+ val keyId = tryGetId(key)
+ assertNotNull(keyId)
+ assertIs<GpgIdentifier.KeyId>(keyId)
+ }
+}
diff --git a/crypto-pgpainless/src/test/kotlin/dev/msfjarvis/aps/crypto/TestUtils.kt b/crypto-pgpainless/src/test/kotlin/dev/msfjarvis/aps/crypto/TestUtils.kt
index ab9b6bf1..d002180d 100644
--- a/crypto-pgpainless/src/test/kotlin/dev/msfjarvis/aps/crypto/TestUtils.kt
+++ b/crypto-pgpainless/src/test/kotlin/dev/msfjarvis/aps/crypto/TestUtils.kt
@@ -2,10 +2,15 @@
* Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
* SPDX-License-Identifier: GPL-3.0-only
*/
+@file:Suppress("RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS")
package dev.msfjarvis.aps.crypto
object TestUtils {
fun getArmoredPrivateKey() = this::class.java.classLoader.getResource("private_key").readBytes()
fun getArmoredPublicKey() = this::class.java.classLoader.getResource("public_key").readBytes()
+ fun getArmoredPrivateKeyWithMultipleIdentities() =
+ this::class.java.classLoader.getResource("private_key_multiple_identities").readBytes()
+ fun getArmoredPublicKeyWithMultipleIdentities() =
+ this::class.java.classLoader.getResource("public_key_multiple_identities").readBytes()
}