diff options
Diffstat (limited to 'crypto-pgpainless/src/test')
3 files changed, 69 insertions, 0 deletions
diff --git a/crypto-pgpainless/src/test/kotlin/app/passwordstore/crypto/PGPKeyManagerTest.kt b/crypto-pgpainless/src/test/kotlin/app/passwordstore/crypto/PGPKeyManagerTest.kt index b491206b..1bb8553c 100644 --- a/crypto-pgpainless/src/test/kotlin/app/passwordstore/crypto/PGPKeyManagerTest.kt +++ b/crypto-pgpainless/src/test/kotlin/app/passwordstore/crypto/PGPKeyManagerTest.kt @@ -17,6 +17,7 @@ import kotlin.test.Test import kotlin.test.assertContentEquals import kotlin.test.assertEquals import kotlin.test.assertIs +import kotlin.test.assertNotEquals import kotlin.test.assertNotNull import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -225,4 +226,40 @@ class PGPKeyManagerTest { assertIs<Err<KeyAlreadyExistsException>>(keyManager.addKey(secretKey)) } } + + @Test + fun addMultipleKeysWithSameEmail() { + scope.runTest { + val alice = + PGPKey(this::class.java.classLoader.getResource("alice_owner@example_com")!!.readBytes()) + val bobby = + PGPKey(this::class.java.classLoader.getResource("bobby_owner@example_com")!!.readBytes()) + assertIs<Ok<PGPKey>>(keyManager.addKey(alice)) + assertIs<Ok<PGPKey>>(keyManager.addKey(bobby)) + + keyManager.getAllKeys().apply { + assertIs<Ok<List<PGPKey>>>(this) + assertEquals(2, this.value.size) + } + + val longKeyIds = + arrayOf( + KeyId(-7087927403306410599), // Alice + KeyId(-961222705095032109), // Bobby + ) + val userIds = + arrayOf( + UserId("Alice <owner@example.com>"), + UserId("Bobby <owner@example.com>"), + ) + + for (idCollection in arrayOf(longKeyIds, userIds)) { + val alice1 = keyManager.getKeyById(idCollection[0]) + val bobby1 = keyManager.getKeyById(idCollection[1]) + assertIs<Ok<PGPKey>>(alice1) + assertIs<Ok<PGPKey>>(bobby1) + assertNotEquals(alice1.value.contents, bobby1.value.contents) + } + } + } } diff --git a/crypto-pgpainless/src/test/resources/alice_owner@example_com b/crypto-pgpainless/src/test/resources/alice_owner@example_com new file mode 100644 index 00000000..d2612b0d --- /dev/null +++ b/crypto-pgpainless/src/test/resources/alice_owner@example_com @@ -0,0 +1,16 @@ +-----BEGIN PGP PRIVATE KEY BLOCK----- + +lIYEY2to0BYJKwYBBAHaRw8BAQdAuI+Z2XyvQv6qBnA06ZAoKArgfMXFN783oYWl +Vh1DqpT+BwMCSqjdffS3e+X/Kfnv30tVSSrb8j2nX2C+P0ODVvS7xWs8MG8TN33d +NJXWUkfct513yADC520EL2KpXPU6GThIxsYmxBXPdyBb3CAiQQDJWLQZQWxpY2Ug +PG93bmVyQGV4YW1wbGUuY29tPoiQBBMWCAA4FiEEMqSK1ESF5td0+gNunaKflIQq +HZkFAmNraNACGwMFCwkIBwIGFQoJCAsCBBYCAwECHgECF4AACgkQnaKflIQqHZk6 +sAD/Xx8MQbtXcKPJi/0UGXkyRHEYbcC+zzhECFalHsQsNh0A/3Naih9zRixXt3v0 +JVCv7fbKaXpfKdGi8tj9muSa+5QBnIsEY2to0BIKKwYBBAGXVQEFAQEHQJqcQkrg +shQO4tyyshE9Ng74LAdu4zRD/yb9aQet+61BAwEIB/4HAwIEJ6OJJ8OAFf/0IyRK +Frmj2UHklu1UT1P2JPF5RPzgPlAxZB1eGHFcCQoJX/ro2AsbQ5KZUwraSs1QgX5b +GKAdcyJqFwtbz+pkTpBvOWS6iHgEGBYIACAWIQQypIrURIXm13T6A26dop+UhCod +mQUCY2to0AIbDAAKCRCdop+UhCodmYTSAP0U5Q6clPUsFcjIcwKA+x5G1Q+wzODx +7/pUS2Vg+cKOMAEAuY5wW5k0eCuWMC/uzXy8l2a3BwsMN3nlApuGk0zOcwM= +=ApnA +-----END PGP PRIVATE KEY BLOCK----- diff --git a/crypto-pgpainless/src/test/resources/bobby_owner@example_com b/crypto-pgpainless/src/test/resources/bobby_owner@example_com new file mode 100644 index 00000000..6bd548e7 --- /dev/null +++ b/crypto-pgpainless/src/test/resources/bobby_owner@example_com @@ -0,0 +1,16 @@ +-----BEGIN PGP PRIVATE KEY BLOCK----- + +lIYEY2tpShYJKwYBBAHaRw8BAQdA0syygn/sjv82T226XDe7ZmsJ897HQ88pruR6 +uMSdtYP+BwMCAaOsMuRJoq3/eHOl9Df1jlr3zfIBdw0hQrmcJ2qVOS4xQGDegjLW +Bbqnmjw7cCRUN1knjHdMWYwrnm8G9YmhOhhwHwdmhxw/LJOA00SyVLQZQm9iYnkg +PG93bmVyQGV4YW1wbGUuY29tPoiQBBMWCAA4FiEEPnwcCqistth5tnEB8qkNCuDF +QtMFAmNraUoCGwMFCwkIBwIGFQoJCAsCBBYCAwECHgECF4AACgkQ8qkNCuDFQtOx +NAD+MzrKYoQQxgLWkqf08Jhc58sa+2xeZBI3Sq0o+huMql0A/39hfDlJnzD61gEZ +vwOeZuTNb+LH23ha2uG8UpoMx4oLnIsEY2tpShIKKwYBBAGXVQEFAQEHQIVF4gjr +Wpw7KN/IYZQdml9Rn7zlBMsXNIxXhcMVjxlZAwEIB/4HAwJenw1L/ZS8WP+e3uzg +khxkk1dQ3fZbTaR90z0wzLDGngVJO1J2XmfIPnTeU8conEeak8Yyt8+85QdM9MK0 +ch0MyhEa/8hRgtCL8Fo3XkLKiHgEGBYIACAWIQQ+fBwKqKy22Hm2cQHyqQ0K4MVC +0wUCY2tpSgIbDAAKCRDyqQ0K4MVC04+aAQDEW/aasrpOYw35DIddH/Wp4tSrWi65 +kv18HvDPl/c6KwEAw6ZxYsfWmxMtzY6efTIzVnvb4T3OZEVWG6XetZoDTAI= +=OFsg +-----END PGP PRIVATE KEY BLOCK----- |