diff options
author | Harsh Shandilya <me@msfjarvis.dev> | 2022-10-29 04:36:51 +0530 |
---|---|---|
committer | Harsh Shandilya <me@msfjarvis.dev> | 2022-10-29 04:37:04 +0530 |
commit | b4c9115365ecbdac2127f7b68d8b46ca1975f1da (patch) | |
tree | 68ce3f3bb227583cb0ceb292f71b40be479db5f7 /crypto-pgpainless/src/test | |
parent | 633cbe271460980ff18a350fb6b7864a424ec83a (diff) |
feat(crypto-pgpainless): add a test for ASCII output
Diffstat (limited to 'crypto-pgpainless/src/test')
-rw-r--r-- | crypto-pgpainless/src/test/kotlin/app/passwordstore/crypto/PGPainlessCryptoHandlerTest.kt | 18 |
1 files changed, 18 insertions, 0 deletions
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 386ca72b..8e65cc83 100644 --- a/crypto-pgpainless/src/test/kotlin/app/passwordstore/crypto/PGPainlessCryptoHandlerTest.kt +++ b/crypto-pgpainless/src/test/kotlin/app/passwordstore/crypto/PGPainlessCryptoHandlerTest.kt @@ -13,6 +13,7 @@ import com.google.testing.junit.testparameterinjector.TestParameter import com.google.testing.junit.testparameterinjector.TestParameterInjector import java.io.ByteArrayOutputStream import kotlin.test.Test +import kotlin.test.assertContains import kotlin.test.assertEquals import kotlin.test.assertFalse import kotlin.test.assertIs @@ -82,6 +83,23 @@ class PGPainlessCryptoHandlerTest { } @Test + fun encryptAsciiArmored() { + val ciphertextStream = ByteArrayOutputStream() + val encryptRes = + cryptoHandler.encrypt( + encryptionKey.keySet, + CryptoConstants.PLAIN_TEXT.byteInputStream(Charsets.UTF_8), + ciphertextStream, + PGPEncryptOptions.Builder().withAsciiArmor(true).build(), + ) + assertIs<Ok<Unit>>(encryptRes) + val ciphertext = ciphertextStream.toString(Charsets.UTF_8) + assertContains(ciphertext, "Version: PGPainless") + assertContains(ciphertext, "-----BEGIN PGP MESSAGE-----") + assertContains(ciphertext, "-----END PGP MESSAGE-----") + } + + @Test fun canHandleFiltersFormats() { assertFalse { cryptoHandler.canHandle("example.com") } assertTrue { cryptoHandler.canHandle("example.com.gpg") } |