aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/test/java/dev/msfjarvis/aps/util/crypto/GpgIdentifierTest.kt
blob: efb08f7b66ed1ca802a0497f02bf1bb9cd2bc712 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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 }
    }
}