From 0c8bed4e546ac248be118b41cfa4b002a357e12f Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Wed, 5 Jul 2023 02:40:31 +0530 Subject: feat(crypto-pgpainless): run usability test when adding keys --- .../src/test/kotlin/app/passwordstore/crypto/PGPKeyManagerTest.kt | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'crypto-pgpainless/src/test/kotlin') 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 43a62bd7..85cf8e1b 100644 --- a/crypto-pgpainless/src/test/kotlin/app/passwordstore/crypto/PGPKeyManagerTest.kt +++ b/crypto-pgpainless/src/test/kotlin/app/passwordstore/crypto/PGPKeyManagerTest.kt @@ -6,6 +6,7 @@ import app.passwordstore.crypto.PGPIdentifier.UserId import app.passwordstore.crypto.errors.KeyAlreadyExistsException import app.passwordstore.crypto.errors.KeyNotFoundException import app.passwordstore.crypto.errors.NoKeysAvailableException +import app.passwordstore.crypto.errors.UnusableKeyException import com.github.michaelbull.result.Err import com.github.michaelbull.result.Ok import com.github.michaelbull.result.unwrap @@ -70,6 +71,13 @@ class PGPKeyManagerTest { assertEquals(KeyId(CryptoConstants.KEY_ID), keyId) } + @Test + fun addKeyWithUnusableKey() = + runTest(dispatcher) { + val error = keyManager.addKey(PGPKey(TestUtils.getAEADSecretKey())).unwrapError() + assertEquals(UnusableKeyException, error) + } + @Test fun removeKey() = runTest(dispatcher) { -- cgit v1.2.3