Skip to content

Commit

Permalink
Add test for COSE serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
nodh committed Dec 11, 2024
1 parent 685a7b4 commit 8a7bb7e
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,18 @@ class CoseSerializationTest : FreeSpec({
Json.decodeFromString<CoseSigned<ByteArray>>(Json.encodeToString(cose)) shouldBe cose
}

"Serialization is correct with JSON for data class" {
val payload = DataClass("This is the content.")
val cose = CoseSigned<DataClass>(
protectedHeader = CoseHeader(algorithm = CoseAlgorithm.ES256),
unprotectedHeader = CoseHeader(),
payload = payload,
signature = CryptoSignature.RSAorHMAC("bar".encodeToByteArray())
)

Json.decodeFromString<CoseSigned<DataClass>>(Json.encodeToString(cose)) shouldBe cose
}

"Serialization is correct for data class" {
val payload = DataClass("This is the content.")
val cose = CoseSigned(
Expand Down

0 comments on commit 8a7bb7e

Please sign in to comment.