forked from TrueCloudLab/frostfs-api-go
[#150] sdk/token: Add owner ID
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
73220620c5
commit
0259a06783
4 changed files with 104 additions and 34 deletions
42
pkg/token/session_test.go
Normal file
42
pkg/token/session_test.go
Normal file
|
@ -0,0 +1,42 @@
|
|||
package token
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"testing"
|
||||
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/owner"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestSessionToken_SetID(t *testing.T) {
|
||||
token := NewSessionToken()
|
||||
|
||||
id := []byte{1, 2, 3}
|
||||
token.SetID(id)
|
||||
|
||||
require.Equal(t, id, token.ID())
|
||||
}
|
||||
|
||||
func TestSessionToken_SetOwnerID(t *testing.T) {
|
||||
token := NewSessionToken()
|
||||
|
||||
w := new(owner.NEO3Wallet)
|
||||
_, err := rand.Read(w.Bytes())
|
||||
require.NoError(t, err)
|
||||
|
||||
ownerID := owner.NewID()
|
||||
ownerID.SetNeo3Wallet(w)
|
||||
|
||||
token.SetOwnerID(ownerID)
|
||||
|
||||
require.Equal(t, ownerID, token.OwnerID())
|
||||
}
|
||||
|
||||
func TestSessionToken_SetSessionKey(t *testing.T) {
|
||||
token := NewSessionToken()
|
||||
|
||||
key := []byte{1, 2, 3}
|
||||
token.SetSessionKey(key)
|
||||
|
||||
require.Equal(t, key, token.SessionKey())
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue