[CORDA-2512] - Adjust uploadAttachmentWithMetadata RPC to use privileged import (#4750)

This commit is contained in:
Dimos Raptis 2019-02-13 15:52:08 +00:00 committed by josecoll
parent b65ebdd116
commit e6c6c69266
2 changed files with 11 additions and 1 deletions

View File

@ -210,7 +210,7 @@ internal class CordaRPCOpsImpl(
}
override fun uploadAttachmentWithMetadata(jar: InputStream, uploader: String, filename: String): SecureHash {
return services.attachments.importAttachment(jar, uploader, filename)
return services.attachments.privilegedImportAttachment(jar, uploader, filename)
}
override fun queryAttachments(query: AttachmentQueryCriteria, sorting: AttachmentSort?): List<AttachmentId> {

View File

@ -15,6 +15,7 @@ import net.corda.core.flows.FlowLogic
import net.corda.core.flows.StartableByRPC
import net.corda.core.flows.StateMachineRunId
import net.corda.core.identity.Party
import net.corda.core.internal.RPC_UPLOADER
import net.corda.core.internal.uncheckedCast
import net.corda.core.messaging.*
import net.corda.core.node.services.StatesNotAvailableException
@ -333,6 +334,15 @@ class CordaRPCOpsImplTest {
}
}
@Test
fun `attachment uploaded with metadata can be from a privileged user`() {
withPermissions(invokeRpc(CordaRPCOps::uploadAttachmentWithMetadata), invokeRpc(CordaRPCOps::attachmentExists)) {
val inputJar = Thread.currentThread().contextClassLoader.getResourceAsStream(testJar)
val secureHash = rpc.uploadAttachmentWithMetadata(inputJar, RPC_UPLOADER, "Season 1")
assertTrue(rpc.attachmentExists(secureHash))
}
}
@Test
fun `attachment uploaded with metadata has specified uploader`() {
withPermissions(invokeRpc(CordaRPCOps::uploadAttachmentWithMetadata), invokeRpc(CordaRPCOps::queryAttachments)) {