forked from TrueCloudLab/frostfs-api-go
[#283] pkg/container: Add session token and signature to Container
Container can be created within a session, and should be signed. Add `SessionToken` / `SetSessionToken` (`Signature` / `SetSignature`) methods to carry session token (signature) in `Container` structure. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
f60f7e0cdb
commit
fcbe0bbd2e
2 changed files with 50 additions and 0 deletions
|
@ -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())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue