From c4f7be19ea14c056ff92a80bc737cd104148677c Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Thu, 24 Dec 2020 12:51:59 +0300 Subject: [PATCH] [#194] pkg/client: Verify container format in GetContainer method Make Client.GetContainer method to return an error if received container structure does not meet NeoFS API specification. Signed-off-by: Leonard Lyubich --- pkg/client/container.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/client/container.go b/pkg/client/container.go index d28bec7..29b9871 100644 --- a/pkg/client/container.go +++ b/pkg/client/container.go @@ -55,6 +55,9 @@ func (c Client) PutContainer(ctx context.Context, cnr *container.Container, opts } } +// GetContainer receives container structure through NeoFS API call. +// +// Returns error if container structure is received but does not meet NeoFS API specification. func (c Client) GetContainer(ctx context.Context, id *container.ID, opts ...CallOption) (*container.Container, error) { switch c.remoteNode.Version.Major() { case 2: @@ -259,7 +262,7 @@ func (c Client) getContainerV2(ctx context.Context, id *container.ID, opts ...Ca return nil, errors.Wrap(err, "can't verify response message") } - return container.NewContainerFromV2(resp.GetBody().GetContainer()), nil + return container.NewVerifiedFromV2(resp.GetBody().GetContainer()) default: return nil, errUnsupportedProtocol }