feat(crypto-pgpainless): add a test for ASCII output
This commit is contained in:
parent
633cbe2714
commit
b4c9115365
1 changed files with 18 additions and 0 deletions
|
@ -13,6 +13,7 @@ import com.google.testing.junit.testparameterinjector.TestParameter
|
||||||
import com.google.testing.junit.testparameterinjector.TestParameterInjector
|
import com.google.testing.junit.testparameterinjector.TestParameterInjector
|
||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
import kotlin.test.Test
|
import kotlin.test.Test
|
||||||
|
import kotlin.test.assertContains
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
import kotlin.test.assertFalse
|
import kotlin.test.assertFalse
|
||||||
import kotlin.test.assertIs
|
import kotlin.test.assertIs
|
||||||
|
@ -81,6 +82,23 @@ class PGPainlessCryptoHandlerTest {
|
||||||
assertIs<IncorrectPassphraseException>(result.getError())
|
assertIs<IncorrectPassphraseException>(result.getError())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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
|
@Test
|
||||||
fun canHandleFiltersFormats() {
|
fun canHandleFiltersFormats() {
|
||||||
assertFalse { cryptoHandler.canHandle("example.com") }
|
assertFalse { cryptoHandler.canHandle("example.com") }
|
||||||
|
|
Loading…
Reference in a new issue