diff --git a/pkg/container/container.go b/pkg/container/container.go index f4a52a1d..f758d1c7 100644 --- a/pkg/container/container.go +++ b/pkg/container/container.go @@ -7,11 +7,16 @@ import ( "github.com/nspcc-dev/neofs-api-go/pkg" "github.com/nspcc-dev/neofs-api-go/pkg/netmap" "github.com/nspcc-dev/neofs-api-go/pkg/owner" + "github.com/nspcc-dev/neofs-api-go/pkg/token" "github.com/nspcc-dev/neofs-api-go/v2/container" ) type Container struct { v2 container.Container + + token *token.SessionToken + + sig *pkg.Signature } func New(opts ...NewOption) *Container { @@ -152,6 +157,28 @@ func (c *Container) SetPlacementPolicy(v *netmap.PlacementPolicy) { c.v2.SetPlacementPolicy(v.ToV2()) } +// SessionToken returns token of the session within +// which container was created. +func (c Container) SessionToken() *token.SessionToken { + return c.token +} + +// SetSessionToken sets token of the session within +// which container was created. +func (c *Container) SetSessionToken(t *token.SessionToken) { + c.token = t +} + +// Signature returns signature of the marshaled container. +func (c Container) Signature() *pkg.Signature { + return c.sig +} + +// SetSignature sets signature of the marshaled container. +func (c *Container) SetSignature(sig *pkg.Signature) { + c.sig = sig +} + // Marshal marshals Container into a protobuf binary form. // // Buffer is allocated when the argument is empty. diff --git a/pkg/container/container_test.go b/pkg/container/container_test.go index f4739ab4..d1fb7bd5 100644 --- a/pkg/container/container_test.go +++ b/pkg/container/container_test.go @@ -10,6 +10,7 @@ import ( "github.com/nspcc-dev/neofs-api-go/pkg/container" "github.com/nspcc-dev/neofs-api-go/pkg/netmap" "github.com/nspcc-dev/neofs-api-go/pkg/owner" + "github.com/nspcc-dev/neofs-api-go/pkg/token" "github.com/nspcc-dev/neofs-crypto/test" "github.com/stretchr/testify/require" ) @@ -95,3 +96,25 @@ func TestContainerEncoding(t *testing.T) { require.Equal(t, c, c2) }) } + +func TestContainer_SessionToken(t *testing.T) { + tok := token.NewSessionToken() + tok.SetID([]byte{1, 2, 3}) + + cnr := container.New() + + cnr.SetSessionToken(tok) + + require.Equal(t, tok, cnr.SessionToken()) +} + +func TestContainer_Signature(t *testing.T) { + sig := pkg.NewSignature() + sig.SetKey([]byte{1, 2, 3}) + sig.SetSign([]byte{4, 5, 6}) + + cnr := container.New() + cnr.SetSignature(sig) + + require.Equal(t, sig, cnr.Signature()) +}