From c4a3adc8b0789a26847ef611f1c793ad27985f14 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Tue, 25 May 2021 19:11:15 +0300 Subject: [PATCH] [#525] morph/container: Attach all parsed items to container in Get Unmarshal session token from `GetValues` and write it to resulting `Container` structure in `Wrapper.Get` method. Write key-signature pair from `GetValues` to resulting `Container` structure in `Wrapper.Get` method. Signed-off-by: Leonard Lyubich --- .../client/container/wrapper/container.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pkg/morph/client/container/wrapper/container.go b/pkg/morph/client/container/wrapper/container.go index 0abfe33a0..7d5be7963 100644 --- a/pkg/morph/client/container/wrapper/container.go +++ b/pkg/morph/client/container/wrapper/container.go @@ -9,6 +9,7 @@ import ( "github.com/nspcc-dev/neofs-api-go/pkg/container" cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id" "github.com/nspcc-dev/neofs-api-go/pkg/owner" + "github.com/nspcc-dev/neofs-api-go/pkg/session" v2refs "github.com/nspcc-dev/neofs-api-go/v2/refs" core "github.com/nspcc-dev/neofs-node/pkg/core/container" client "github.com/nspcc-dev/neofs-node/pkg/morph/client/container" @@ -127,6 +128,24 @@ func (w *Wrapper) Get(cid []byte) (*container.Container, error) { return nil, fmt.Errorf("can't unmarshal container: %w", err) } + binToken := rpcAnswer.SessionToken() + if len(binToken) > 0 { + tok := session.NewToken() + + err = tok.Unmarshal(binToken) + if err != nil { + return nil, fmt.Errorf("could not unmarshal session token: %w", err) + } + + cnr.SetSessionToken(tok) + } + + sig := pkg.NewSignature() + sig.SetKey(rpcAnswer.PublicKey()) + sig.SetSign(rpcAnswer.Signature()) + + cnr.SetSignature(sig) + return cnr, nil }