forked from TrueCloudLab/frostfs-api-go
session: change PrivateToken interface methods
This commit replaces PublicKey() and SignData() methods of PrivateToken with PrivateKey() in order to have the ability to sign data with session key using service package functions.
This commit is contained in:
parent
ba27e296c3
commit
af28735ca6
3 changed files with 7 additions and 39 deletions
|
@ -1,35 +1,16 @@
|
|||
package session
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"testing"
|
||||
|
||||
crypto "github.com/nspcc-dev/neofs-crypto"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestPrivateToken(t *testing.T) {
|
||||
func TestPToken_PrivateKey(t *testing.T) {
|
||||
// create new private token
|
||||
pToken, err := NewPrivateToken(0)
|
||||
require.NoError(t, err)
|
||||
|
||||
// generate data to sign
|
||||
data := make([]byte, 10)
|
||||
_, err = rand.Read(data)
|
||||
require.NoError(t, err)
|
||||
|
||||
// sign data via private token
|
||||
sig, err := pToken.Sign(data)
|
||||
require.NoError(t, err)
|
||||
|
||||
// check signature
|
||||
require.NoError(t,
|
||||
crypto.Verify(
|
||||
crypto.UnmarshalPublicKey(pToken.PublicKey()),
|
||||
data,
|
||||
sig,
|
||||
),
|
||||
)
|
||||
require.NotNil(t, pToken.PrivateKey())
|
||||
}
|
||||
|
||||
func TestPToken_Expired(t *testing.T) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue