forked from TrueCloudLab/frostfs-sdk-go
[#193] pool: Add test to check side effects in token cache
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
e0281c3b34
commit
f38a24e8b5
1 changed files with 32 additions and 0 deletions
|
@ -4,6 +4,9 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
|
"github.com/nspcc-dev/neofs-sdk-go/session"
|
||||||
|
sessiontest "github.com/nspcc-dev/neofs-sdk-go/session/test"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -29,3 +32,32 @@ func TestSessionCache_GetAccessTime(t *testing.T) {
|
||||||
require.True(t, ok)
|
require.True(t, ok)
|
||||||
require.NotEqual(t, t1, t3)
|
require.NotEqual(t, t1, t3)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSessionCache_GetUnmodifiedToken(t *testing.T) {
|
||||||
|
const key = "Foo"
|
||||||
|
target := sessiontest.Token()
|
||||||
|
|
||||||
|
pk, err := keys.NewPrivateKey()
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
check := func(t *testing.T, tok *session.Token, extra string) {
|
||||||
|
require.Empty(t, tok.Signature().Sign(), extra)
|
||||||
|
require.Nil(t, tok.Context(), extra)
|
||||||
|
}
|
||||||
|
|
||||||
|
cache, err := newCache()
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
cache.Put(key, target)
|
||||||
|
value := cache.Get(key)
|
||||||
|
check(t, value, "before sign")
|
||||||
|
|
||||||
|
err = value.Sign(&pk.PrivateKey)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
octx := sessiontest.ObjectContext()
|
||||||
|
value.SetContext(octx)
|
||||||
|
|
||||||
|
value = cache.Get(key)
|
||||||
|
check(t, value, "after sign")
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue