mirror of
https://github.com/corda/corda.git
synced 2025-06-23 09:25:36 +00:00
CORDA-2595 - check that all attachments are trusted before loading (#4763)
CORDA-2595 - Fix test and api. CORDA-2595 add test CORDA-2595 fix tests CORDA-2595 fix test and address code review comments CORDA-2595 address code review comments
This commit is contained in:
committed by
Tommy Lillehagen
parent
37f9eb31f7
commit
3d362e066c
@ -40,7 +40,7 @@ class ContractAttachmentSerializerTest {
|
||||
|
||||
@Test
|
||||
fun `write contract attachment and read it back`() {
|
||||
val contractAttachment = ContractAttachment(GeneratedAttachment(EMPTY_BYTE_ARRAY), DummyContract.PROGRAM_ID)
|
||||
val contractAttachment = ContractAttachment(GeneratedAttachment(EMPTY_BYTE_ARRAY, "test"), DummyContract.PROGRAM_ID)
|
||||
// no token context so will serialize the whole attachment
|
||||
val serialized = contractAttachment.checkpointSerialize()
|
||||
val deserialized = serialized.checkpointDeserialize()
|
||||
@ -53,7 +53,7 @@ class ContractAttachmentSerializerTest {
|
||||
|
||||
@Test
|
||||
fun `write contract attachment and read it back using token context`() {
|
||||
val attachment = GeneratedAttachment("test".toByteArray())
|
||||
val attachment = GeneratedAttachment("test".toByteArray(), "test")
|
||||
|
||||
mockServices.attachments.importAttachment(attachment.open(), "test", null)
|
||||
|
||||
@ -70,7 +70,7 @@ class ContractAttachmentSerializerTest {
|
||||
@Test
|
||||
fun `check only serialize attachment id and contract class name when using token context`() {
|
||||
val largeAttachmentSize = 1024 * 1024
|
||||
val attachment = GeneratedAttachment(ByteArray(largeAttachmentSize))
|
||||
val attachment = GeneratedAttachment(ByteArray(largeAttachmentSize), "test")
|
||||
|
||||
mockServices.attachments.importAttachment(attachment.open(), "test", null)
|
||||
|
||||
@ -82,7 +82,7 @@ class ContractAttachmentSerializerTest {
|
||||
|
||||
@Test
|
||||
fun `throws when missing attachment when using token context`() {
|
||||
val attachment = GeneratedAttachment("test".toByteArray())
|
||||
val attachment = GeneratedAttachment("test".toByteArray(), "test")
|
||||
|
||||
// don't importAttachment in mockService
|
||||
|
||||
@ -95,7 +95,7 @@ class ContractAttachmentSerializerTest {
|
||||
|
||||
@Test
|
||||
fun `check attachment in deserialize is lazy loaded when using token context`() {
|
||||
val attachment = GeneratedAttachment(EMPTY_BYTE_ARRAY)
|
||||
val attachment = GeneratedAttachment(EMPTY_BYTE_ARRAY, "test")
|
||||
// don't importAttachment in mockService
|
||||
|
||||
val contractAttachment = ContractAttachment(attachment, DummyContract.PROGRAM_ID)
|
||||
|
@ -1304,7 +1304,7 @@ class SerializationOutputTests(private val compression: CordaSerializationEncodi
|
||||
)
|
||||
factory2.register(net.corda.serialization.internal.amqp.custom.ContractAttachmentSerializer(factory2))
|
||||
|
||||
val obj = ContractAttachment(GeneratedAttachment("test".toByteArray()), DummyContract.PROGRAM_ID)
|
||||
val obj = ContractAttachment(GeneratedAttachment("test".toByteArray(), "test"), DummyContract.PROGRAM_ID)
|
||||
val obj2 = serdes(obj, factory, factory2, expectedEqual = false, expectDeserializedEqual = false)
|
||||
assertEquals(obj.id, obj2.attachment.id)
|
||||
assertEquals(obj.contract, obj2.contract)
|
||||
@ -1324,7 +1324,7 @@ class SerializationOutputTests(private val compression: CordaSerializationEncodi
|
||||
)
|
||||
factory2.register(net.corda.serialization.internal.amqp.custom.ContractAttachmentSerializer(factory2))
|
||||
|
||||
val obj = ContractAttachment(object : AbstractAttachment({ throw Exception() }) {
|
||||
val obj = ContractAttachment(object : AbstractAttachment({ throw Exception() }, "test") {
|
||||
override val id = SecureHash.zeroHash
|
||||
}, DummyContract.PROGRAM_ID)
|
||||
|
||||
|
Reference in New Issue
Block a user