mirror of
https://github.com/corda/corda.git
synced 2025-04-07 11:27:01 +00:00
[CORDA-2512] - Adjust uploadAttachmentWithMetadata RPC to use privileged import (#4750)
This commit is contained in:
parent
b65ebdd116
commit
e6c6c69266
@ -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> {
|
||||
|
@ -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)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user