summaryrefslogtreecommitdiff
path: root/crypto-pgpainless/src/test/kotlin
diff options
context:
space:
mode:
Diffstat (limited to 'crypto-pgpainless/src/test/kotlin')
-rw-r--r--crypto-pgpainless/src/test/kotlin/dev/msfjarvis/aps/crypto/PGPKeyManagerTest.kt2
-rw-r--r--crypto-pgpainless/src/test/kotlin/dev/msfjarvis/aps/crypto/PGPainlessCryptoHandlerTest.kt11
-rw-r--r--crypto-pgpainless/src/test/kotlin/dev/msfjarvis/aps/crypto/TestUtils.kt3
3 files changed, 9 insertions, 7 deletions
diff --git a/crypto-pgpainless/src/test/kotlin/dev/msfjarvis/aps/crypto/PGPKeyManagerTest.kt b/crypto-pgpainless/src/test/kotlin/dev/msfjarvis/aps/crypto/PGPKeyManagerTest.kt
index c547bdd4..ed2b00c3 100644
--- a/crypto-pgpainless/src/test/kotlin/dev/msfjarvis/aps/crypto/PGPKeyManagerTest.kt
+++ b/crypto-pgpainless/src/test/kotlin/dev/msfjarvis/aps/crypto/PGPKeyManagerTest.kt
@@ -28,7 +28,7 @@ class PGPKeyManagerTest {
private val dispatcher = StandardTestDispatcher()
private val scope = TestScope(dispatcher)
private val keyManager by unsafeLazy { PGPKeyManager(filesDir.absolutePath, dispatcher) }
- private val key = Key(TestUtils.getArmoredPrivateKey().encodeToByteArray())
+ private val key = Key(TestUtils.getArmoredPrivateKey())
private fun <T> unsafeLazy(initializer: () -> T) =
lazy(LazyThreadSafetyMode.NONE) { initializer.invoke() }
diff --git a/crypto-pgpainless/src/test/kotlin/dev/msfjarvis/aps/crypto/PGPainlessCryptoHandlerTest.kt b/crypto-pgpainless/src/test/kotlin/dev/msfjarvis/aps/crypto/PGPainlessCryptoHandlerTest.kt
index c5afeaa2..6ec6ccee 100644
--- a/crypto-pgpainless/src/test/kotlin/dev/msfjarvis/aps/crypto/PGPainlessCryptoHandlerTest.kt
+++ b/crypto-pgpainless/src/test/kotlin/dev/msfjarvis/aps/crypto/PGPainlessCryptoHandlerTest.kt
@@ -14,19 +14,20 @@ import kotlin.test.assertTrue
class PGPainlessCryptoHandlerTest {
private val cryptoHandler = PGPainlessCryptoHandler()
+ private val privateKey = Key(TestUtils.getArmoredPrivateKey())
+ private val publicKey = Key(TestUtils.getArmoredPublicKey())
@Test
- fun encrypt_and_decrypt() {
- val key = TestUtils.getArmoredPrivateKey()
+ fun encryptAndDecrypt() {
val ciphertextStream = ByteArrayOutputStream()
cryptoHandler.encrypt(
- listOf(key),
+ listOf(publicKey),
CryptoConstants.PLAIN_TEXT.byteInputStream(Charsets.UTF_8),
ciphertextStream,
)
val plaintextStream = ByteArrayOutputStream()
cryptoHandler.decrypt(
- key,
+ privateKey,
CryptoConstants.KEY_PASSPHRASE,
ciphertextStream.toByteArray().inputStream(),
plaintextStream,
@@ -35,7 +36,7 @@ class PGPainlessCryptoHandlerTest {
}
@Test
- fun can_handle_filters_formats() {
+ fun canHandleFiltersFormats() {
assertFalse { cryptoHandler.canHandle("example.com") }
assertTrue { cryptoHandler.canHandle("example.com.gpg") }
assertFalse { cryptoHandler.canHandle("example.com.asc") }
diff --git a/crypto-pgpainless/src/test/kotlin/dev/msfjarvis/aps/crypto/TestUtils.kt b/crypto-pgpainless/src/test/kotlin/dev/msfjarvis/aps/crypto/TestUtils.kt
index 1e01da51..ab9b6bf1 100644
--- a/crypto-pgpainless/src/test/kotlin/dev/msfjarvis/aps/crypto/TestUtils.kt
+++ b/crypto-pgpainless/src/test/kotlin/dev/msfjarvis/aps/crypto/TestUtils.kt
@@ -6,5 +6,6 @@
package dev.msfjarvis.aps.crypto
object TestUtils {
- fun getArmoredPrivateKey() = this::class.java.classLoader.getResource("private_key").readText()
+ fun getArmoredPrivateKey() = this::class.java.classLoader.getResource("private_key").readBytes()
+ fun getArmoredPublicKey() = this::class.java.classLoader.getResource("public_key").readBytes()
}