[#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 <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-05-25 19:11:15 +03:00 committed by Leonard Lyubich
parent b9b369dd5b
commit c4a3adc8b0

View file

@ -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
}