From 396210409d6e297203f60fee6f76104ee0e477ba Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Mon, 24 May 2021 21:48:30 +0300 Subject: [PATCH] [#283] client/container: Write new fields to container in GetContainer Call `SetSessionToken` and `SetSignature` methods on resulting container with items from response body. Signed-off-by: Leonard Lyubich --- pkg/client/container.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/pkg/client/container.go b/pkg/client/container.go index 369fc59e..f0888dfd 100644 --- a/pkg/client/container.go +++ b/pkg/client/container.go @@ -9,6 +9,7 @@ import ( "github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl" "github.com/nspcc-dev/neofs-api-go/pkg/container" "github.com/nspcc-dev/neofs-api-go/pkg/owner" + "github.com/nspcc-dev/neofs-api-go/pkg/session" "github.com/nspcc-dev/neofs-api-go/rpc/client" "github.com/nspcc-dev/neofs-api-go/util/signature" v2container "github.com/nspcc-dev/neofs-api-go/v2/container" @@ -169,7 +170,22 @@ func (c *clientImpl) GetContainer(ctx context.Context, id *container.ID, opts .. return nil, fmt.Errorf("can't verify response message: %w", err) } - return container.NewVerifiedFromV2(resp.GetBody().GetContainer()) + body := resp.GetBody() + + cnr, err := container.NewVerifiedFromV2(body.GetContainer()) + if err != nil { + return nil, err + } + + cnr.SetSessionToken( + session.NewTokenFromV2(body.GetSessionToken()), + ) + + cnr.SetSignature( + pkg.NewSignatureFromV2(body.GetSignature()), + ) + + return cnr, nil } // GetVerifiedContainerStructure is a wrapper over Client.GetContainer method