2022-02-02 11:18:05 +00:00
|
|
|
package pool
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2023-04-25 09:11:42 +00:00
|
|
|
"github.com/nspcc-dev/neofs-sdk-go/crypto/test"
|
2022-04-06 08:03:41 +00:00
|
|
|
"github.com/nspcc-dev/neofs-sdk-go/session"
|
|
|
|
sessiontest "github.com/nspcc-dev/neofs-sdk-go/session/test"
|
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
|
|
|
|
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")
|
|
|
|
|
2023-04-25 09:11:42 +00:00
|
|
|
err = value.Sign(test.RandomSigner(t))
|
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")
|
|
|
|
}
|