Skip to content

Commit

Permalink
test(symmetric): tests for decrypting with individual parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
jhdcruz committed Jul 28, 2023
1 parent 5113491 commit 4a0e7a6
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ internal class SymmetricEncryptionTest {
assertEquals(message.decodeToString(), decrypted.decodeToString())
}

@ParameterizedTest
@MethodSource("io.github.jhdcruz.kipher.symmetric.SymmetricTestParams#getStandardClasses")
fun `Standard encryption test with parameters`(encryptionClass: Class<out StandardEncryption>) {
val encryption = encryptionClass.getDeclaredConstructor().newInstance()

val encrypted = encryption.encrypt(message)
val decrypted = encryption.decrypt(encrypted["data"]!!, encrypted["key"]!!)

assertEquals(message.decodeToString(), decrypted.decodeToString())
}

@ParameterizedTest
@MethodSource("io.github.jhdcruz.kipher.symmetric.SymmetricTestParams#getAeadClasses")
fun `AEAD encryption test`(encryptionClass: Class<out AEAD>) {
Expand Down Expand Up @@ -67,4 +78,16 @@ internal class SymmetricEncryptionTest {

assertEquals(message.decodeToString(), decrypted.decodeToString())
}

@ParameterizedTest
@MethodSource("io.github.jhdcruz.kipher.symmetric.SymmetricTestParams#getAeadClasses")
fun `AEAD encryption test with parameters`(encryptionClass: Class<out AEAD>) {
val encryption = encryptionClass.getDeclaredConstructor().newInstance()

val encrypted = encryption.encrypt(message, aad)
val decrypted =
encryption.decrypt(encrypted["data"]!!, encrypted["key"]!!, encrypted["aad"]!!)

assertEquals(message.decodeToString(), decrypted.decodeToString())
}
}

0 comments on commit 4a0e7a6

Please sign in to comment.