diff options
author | renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> | 2024-03-17 06:33:48 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-17 06:33:48 +0000 |
commit | 48067b4a01281d1cb3a8f67493ef18994c6396ce (patch) | |
tree | adc7583de34bc41e20ac81c6ea0f7120bddc318f /crypto | |
parent | b01fddaa56d29ed99c627c490ee0a8fd77839dc8 (diff) |
fix(deps): update kotlinresult to v1.1.21 (#2958)
* fix(deps): update kotlinresult to v1.1.21
* refactor: fix deprecation warnings
---------
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/pgpainless/src/test/kotlin/app/passwordstore/crypto/PGPKeyManagerTest.kt | 33 | ||||
-rw-r--r-- | crypto/pgpainless/src/test/kotlin/app/passwordstore/crypto/PGPainlessCryptoHandlerTest.kt | 16 |
2 files changed, 22 insertions, 27 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 85cf8e1b..d0cc693e 100644 --- a/crypto/pgpainless/src/test/kotlin/app/passwordstore/crypto/PGPKeyManagerTest.kt +++ b/crypto/pgpainless/src/test/kotlin/app/passwordstore/crypto/PGPKeyManagerTest.kt @@ -7,8 +7,6 @@ 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 import com.github.michaelbull.result.unwrapError import java.io.File @@ -18,8 +16,8 @@ import kotlin.test.assertEquals import kotlin.test.assertIs import kotlin.test.assertNotEquals import kotlin.test.assertNotNull +import kotlin.test.assertTrue import kotlinx.coroutines.test.StandardTestDispatcher -import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.runTest import org.junit.Rule import org.junit.rules.TemporaryFolder @@ -28,7 +26,6 @@ class PGPKeyManagerTest { @get:Rule val temporaryFolder: TemporaryFolder = TemporaryFolder() private val dispatcher = StandardTestDispatcher() - private val scope = TestScope(dispatcher) private val filesDir by unsafeLazy { temporaryFolder.root } private val keysDir by unsafeLazy { File(filesDir, PGPKeyManager.KEY_DIR_NAME) } private val keyManager by unsafeLazy { PGPKeyManager(filesDir.absolutePath, dispatcher) } @@ -170,24 +167,24 @@ class PGPKeyManagerTest { @Test fun replaceSecretKeyWithPublicKey() = runTest(dispatcher) { - assertIs<Ok<PGPKey>>(keyManager.addKey(secretKey)) - assertIs<Err<KeyAlreadyExistsException>>(keyManager.addKey(publicKey)) + assertTrue(keyManager.addKey(secretKey).isOk) + assertTrue(keyManager.addKey(publicKey).isErr) } @Test fun replacePublicKeyWithSecretKey() = runTest(dispatcher) { - assertIs<Ok<PGPKey>>(keyManager.addKey(publicKey)) - assertIs<Ok<PGPKey>>(keyManager.addKey(secretKey)) + assertTrue(keyManager.addKey(publicKey).isOk) + assertTrue(keyManager.addKey(secretKey).isOk) } @Test fun replacePublicKeyWithPublicKey() = runTest(dispatcher) { - assertIs<Ok<PGPKey>>(keyManager.addKey(publicKey)) - assertIs<Ok<PGPKey>>(keyManager.addKey(publicKey)) + assertTrue(keyManager.addKey(publicKey).isOk) + assertTrue(keyManager.addKey(publicKey).isOk) val allKeys = keyManager.getAllKeys() - assertIs<Ok<List<PGPKey>>>(allKeys) + assertTrue(allKeys.isOk) assertEquals(1, allKeys.value.size) val key = allKeys.value[0] assertContentEquals(publicKey.contents, key.contents) @@ -196,8 +193,8 @@ class PGPKeyManagerTest { @Test fun replaceSecretKeyWithSecretKey() = runTest(dispatcher) { - assertIs<Ok<PGPKey>>(keyManager.addKey(secretKey)) - assertIs<Err<KeyAlreadyExistsException>>(keyManager.addKey(secretKey)) + assertTrue(keyManager.addKey(secretKey).isOk) + assertTrue(keyManager.addKey(secretKey).isErr) } @Test @@ -207,11 +204,11 @@ class PGPKeyManagerTest { 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)) + assertTrue(keyManager.addKey(alice).isOk) + assertTrue(keyManager.addKey(bobby).isOk) keyManager.getAllKeys().apply { - assertIs<Ok<List<PGPKey>>>(this) + assertTrue(this.isOk) assertEquals(2, this.value.size) } val longKeyIds = @@ -228,8 +225,8 @@ class PGPKeyManagerTest { 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) + assertTrue(alice1.isOk) + assertTrue(bobby1.isOk) assertNotEquals(alice1.value.contents, bobby1.value.contents) } } diff --git a/crypto/pgpainless/src/test/kotlin/app/passwordstore/crypto/PGPainlessCryptoHandlerTest.kt b/crypto/pgpainless/src/test/kotlin/app/passwordstore/crypto/PGPainlessCryptoHandlerTest.kt index 8bf6ba1e..4ec4b7fa 100644 --- a/crypto/pgpainless/src/test/kotlin/app/passwordstore/crypto/PGPainlessCryptoHandlerTest.kt +++ b/crypto/pgpainless/src/test/kotlin/app/passwordstore/crypto/PGPainlessCryptoHandlerTest.kt @@ -9,8 +9,6 @@ package app.passwordstore.crypto import app.passwordstore.crypto.CryptoConstants.KEY_PASSPHRASE import app.passwordstore.crypto.CryptoConstants.PLAIN_TEXT import app.passwordstore.crypto.errors.IncorrectPassphraseException -import com.github.michaelbull.result.Err -import com.github.michaelbull.result.Ok import com.github.michaelbull.result.getError import com.google.testing.junit.testparameterinjector.TestParameter import com.google.testing.junit.testparameterinjector.TestParameterInjector @@ -48,7 +46,7 @@ class PGPainlessCryptoHandlerTest { ciphertextStream, PGPEncryptOptions.Builder().build(), ) - assertIs<Ok<Unit>>(encryptRes) + assertTrue(encryptRes.isOk) val plaintextStream = ByteArrayOutputStream() val decryptRes = cryptoHandler.decrypt( @@ -58,7 +56,7 @@ class PGPainlessCryptoHandlerTest { plaintextStream, PGPDecryptOptions.Builder().build(), ) - assertIs<Ok<Unit>>(decryptRes) + assertTrue(decryptRes.isOk) assertEquals(PLAIN_TEXT, plaintextStream.toString(Charsets.UTF_8)) } @@ -72,7 +70,7 @@ class PGPainlessCryptoHandlerTest { ciphertextStream, PGPEncryptOptions.Builder().build(), ) - assertIs<Ok<Unit>>(encryptRes) + assertTrue(encryptRes.isOk) val plaintextStream = ByteArrayOutputStream() val result = cryptoHandler.decrypt( @@ -82,7 +80,7 @@ class PGPainlessCryptoHandlerTest { plaintextStream, PGPDecryptOptions.Builder().build(), ) - assertIs<Err<Throwable>>(result) + assertTrue(result.isErr) assertIs<IncorrectPassphraseException>(result.getError()) } @@ -96,7 +94,7 @@ class PGPainlessCryptoHandlerTest { ciphertextStream, PGPEncryptOptions.Builder().withAsciiArmor(true).build(), ) - assertIs<Ok<Unit>>(encryptRes) + assertTrue(encryptRes.isOk) val ciphertext = ciphertextStream.toString(Charsets.UTF_8) assertContains(ciphertext, "Version: PGPainless") assertContains(ciphertext, "-----BEGIN PGP MESSAGE-----") @@ -118,7 +116,7 @@ class PGPainlessCryptoHandlerTest { ciphertextStream, PGPEncryptOptions.Builder().withAsciiArmor(true).build(), ) - assertIs<Ok<Unit>>(encryptRes) + assertTrue(encryptRes.isOk) val message = ciphertextStream.toByteArray().decodeToString() val info = MessageInspector.determineEncryptionInfoForMessage(message) assertTrue(info.isEncrypted) @@ -135,7 +133,7 @@ class PGPainlessCryptoHandlerTest { plaintextStream, PGPDecryptOptions.Builder().build(), ) - assertIs<Ok<Unit>>(res) + assertTrue(res.isOk) } } |