service: call OwnerKey setter in AddSignKey method implementation

This commit is contained in:
Leonard Lyubich 2020-05-16 15:29:44 +03:00
parent 22af538c98
commit bd261cf566
2 changed files with 33 additions and 2 deletions

View file

@ -5,6 +5,7 @@ import (
"testing"
"github.com/nspcc-dev/neofs-api-go/refs"
crypto "github.com/nspcc-dev/neofs-crypto"
"github.com/nspcc-dev/neofs-crypto/test"
"github.com/stretchr/testify/require"
)
@ -220,3 +221,28 @@ func TestSignToken(t *testing.T) {
require.NoError(t, VerifySignatureWithKey(pk, verifiedToken))
}
}
func TestSignedSessionToken_AddSignKey(t *testing.T) {
// nil SessionToken
s := new(signedSessionToken)
require.NotPanics(t, func() {
s.AddSignKey(nil, nil)
})
// create test public key and signature
pk := &test.DecodeKey(0).PublicKey
sig := []byte{1, 2, 3}
s.SessionToken = new(Token)
// add key-signature pair to SessionToken
s.AddSignKey(sig, pk)
require.Equal(t, sig, s.GetSignature())
require.Equal(t,
crypto.MarshalPublicKey(pk),
s.GetOwnerKey(),
)
}