2022-02-02 11:18:05 +00:00
|
|
|
package pool
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2023-03-07 11:20:03 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/session"
|
|
|
|
sessiontest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/session/test"
|
2022-04-06 08:03:41 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
2022-02-02 11:18:05 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
2022-04-06 08:03:41 +00:00
|
|
|
func TestSessionCache_GetUnmodifiedToken(t *testing.T) {
|
|
|
|
const key = "Foo"
|
2022-04-07 16:09:15 +00:00
|
|
|
target := *sessiontest.Object()
|
2022-04-06 08:03:41 +00:00
|
|
|
|
|
|
|
pk, err := keys.NewPrivateKey()
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2022-04-07 16:09:15 +00:00
|
|
|
check := func(t *testing.T, tok session.Object, extra string) {
|
2022-04-05 11:13:34 +00:00
|
|
|
require.False(t, tok.VerifySignature(), extra)
|
2022-04-06 08:03:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
cache, err := newCache()
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
cache.Put(key, target)
|
2022-04-07 16:09:15 +00:00
|
|
|
value, ok := cache.Get(key)
|
|
|
|
require.True(t, ok)
|
2022-04-06 08:03:41 +00:00
|
|
|
check(t, value, "before sign")
|
|
|
|
|
2022-04-07 16:09:15 +00:00
|
|
|
err = value.Sign(pk.PrivateKey)
|
2022-04-06 08:03:41 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
2022-04-07 16:09:15 +00:00
|
|
|
value, ok = cache.Get(key)
|
|
|
|
require.True(t, ok)
|
2022-04-06 08:03:41 +00:00
|
|
|
check(t, value, "after sign")
|
|
|
|
}
|