From d6464159779dd5c9027429ad636a5fa6a1225bee Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Sat, 16 Jul 2022 23:25:03 +0530 Subject: Add missing asserts to PGPainlessCryptoHandler tests (#2010) Add missing asserts --- .../crypto/PGPainlessCryptoHandlerTest.kt | 39 +++++++++++++--------- 1 file changed, 23 insertions(+), 16 deletions(-) (limited to 'crypto-pgpainless') 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 4dc0abd5..68335a28 100644 --- a/crypto-pgpainless/src/test/kotlin/app/passwordstore/crypto/PGPainlessCryptoHandlerTest.kt +++ b/crypto-pgpainless/src/test/kotlin/app/passwordstore/crypto/PGPainlessCryptoHandlerTest.kt @@ -7,6 +7,7 @@ package app.passwordstore.crypto 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 @@ -35,29 +36,35 @@ class PGPainlessCryptoHandlerTest { @Test fun encryptAndDecrypt() { val ciphertextStream = ByteArrayOutputStream() - cryptoHandler.encrypt( - encryptionKey.keySet, - CryptoConstants.PLAIN_TEXT.byteInputStream(Charsets.UTF_8), - ciphertextStream, - ) + val encryptRes = + cryptoHandler.encrypt( + encryptionKey.keySet, + CryptoConstants.PLAIN_TEXT.byteInputStream(Charsets.UTF_8), + ciphertextStream, + ) + assertIs>(encryptRes) val plaintextStream = ByteArrayOutputStream() - cryptoHandler.decrypt( - privateKey, - CryptoConstants.KEY_PASSPHRASE, - ciphertextStream.toByteArray().inputStream(), - plaintextStream, - ) + val decryptRes = + cryptoHandler.decrypt( + privateKey, + CryptoConstants.KEY_PASSPHRASE, + ciphertextStream.toByteArray().inputStream(), + plaintextStream, + ) + assertIs>(decryptRes) assertEquals(CryptoConstants.PLAIN_TEXT, plaintextStream.toString(Charsets.UTF_8)) } @Test fun decryptWithWrongPassphrase() { val ciphertextStream = ByteArrayOutputStream() - cryptoHandler.encrypt( - encryptionKey.keySet, - CryptoConstants.PLAIN_TEXT.byteInputStream(Charsets.UTF_8), - ciphertextStream, - ) + val encryptRes = + cryptoHandler.encrypt( + encryptionKey.keySet, + CryptoConstants.PLAIN_TEXT.byteInputStream(Charsets.UTF_8), + ciphertextStream, + ) + assertIs>(encryptRes) val plaintextStream = ByteArrayOutputStream() val result = cryptoHandler.decrypt( -- cgit v1.2.3