aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/test/java/dev/msfjarvis/aps/util/crypto/GpgIdentifierTest.kt
blob: 8c3272ef963a843f2b7068d9769ce1580d4105ea (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
39
40
41
/*
 * Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
 * SPDX-License-Identifier: GPL-3.0-only
 */

package dev.msfjarvis.aps.util.crypto

import kotlin.test.Test
import kotlin.test.assertNotNull
import kotlin.test.assertTrue

class GpgIdentifierTest {

  @Test
  fun parseHexKeyIdWithout0xPrefix() {
    val identifier = GpgIdentifier.fromString("79E8208280490C77")
    assertNotNull(identifier)
    assertTrue { identifier is GpgIdentifier.KeyId }
  }

  @Test
  fun parseHexKeyId() {
    val identifier = GpgIdentifier.fromString("0x79E8208280490C77")
    assertNotNull(identifier)
    assertTrue { identifier is GpgIdentifier.KeyId }
  }

  @Test
  fun parseValidEmail() {
    val identifier = GpgIdentifier.fromString("john.doe@example.org")
    assertNotNull(identifier)
    assertTrue { identifier is GpgIdentifier.UserId }
  }

  @Test
  fun parseEmailWithoutTLD() {
    val identifier = GpgIdentifier.fromString("john.doe@example")
    assertNotNull(identifier)
    assertTrue { identifier is GpgIdentifier.UserId }
  }
}