forked from TrueCloudLab/frostfs-node
[#1255] node/session: Add encryption tests
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
01ed366e99
commit
016eaa25f3
1 changed files with 29 additions and 0 deletions
29
pkg/services/session/storage/persistent/encryption_test.go
Normal file
29
pkg/services/session/storage/persistent/encryption_test.go
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
package persistent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"path/filepath"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestTokenStore_Encryption(t *testing.T) {
|
||||||
|
pk, err := keys.NewPrivateKey()
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
ts, err := NewTokenStore(filepath.Join(t.TempDir(), ".storage"), WithEncryptionKey(&pk.PrivateKey))
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
data := []byte("nice encryption, awesome tests")
|
||||||
|
|
||||||
|
encryptedData, err := ts.encrypt(data)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.False(t, bytes.Equal(data, encryptedData))
|
||||||
|
|
||||||
|
decryptedData, err := ts.decrypt(encryptedData)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
require.Equal(t, data, decryptedData)
|
||||||
|
}
|
Loading…
Reference in a new issue