From d34de558f00407f39390cf76375b440c68a6fcf0 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Mon, 31 May 2021 14:34:39 +0300 Subject: [PATCH] [#570] *: Use generator of test owner IDs from API Go lib Signed-off-by: Leonard Lyubich --- pkg/core/object/fmt_test.go | 13 ++++++++----- pkg/local_object_storage/engine/engine_test.go | 6 ++---- pkg/local_object_storage/metabase/db_test.go | 6 ++---- pkg/local_object_storage/shard/shard_test.go | 6 ++---- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/pkg/core/object/fmt_test.go b/pkg/core/object/fmt_test.go index a3fc952ad..2d41b1ed9 100644 --- a/pkg/core/object/fmt_test.go +++ b/pkg/core/object/fmt_test.go @@ -11,10 +11,9 @@ import ( cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test" "github.com/nspcc-dev/neofs-api-go/pkg/object" "github.com/nspcc-dev/neofs-api-go/pkg/owner" - "github.com/nspcc-dev/neofs-api-go/pkg/session" + sessiontest "github.com/nspcc-dev/neofs-api-go/pkg/session/test" "github.com/nspcc-dev/neofs-api-go/pkg/storagegroup" objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object" - crypto "github.com/nspcc-dev/neofs-crypto" "github.com/nspcc-dev/neofs-node/pkg/util/test" "github.com/stretchr/testify/require" ) @@ -94,12 +93,16 @@ func TestFormatValidator_Validate(t *testing.T) { }) t.Run("correct w/ session token", func(t *testing.T) { - tok := session.NewToken() - tok.SetSessionKey(crypto.MarshalPublicKey(&ownerKey.PublicKey)) + w, err := owner.NEO3WalletFromPublicKey(&ownerKey.PublicKey) + require.NoError(t, err) + + tok := sessiontest.Generate() + tok.SetOwnerID(owner.NewIDFromNeo3Wallet(w)) obj := NewRaw() obj.SetContainerID(cidtest.Generate()) - obj.SetSessionToken(tok) + obj.SetSessionToken(sessiontest.Generate()) + obj.SetOwnerID(tok.OwnerID()) require.NoError(t, object.SetIDWithSignature(ownerKey, obj.SDK())) diff --git a/pkg/local_object_storage/engine/engine_test.go b/pkg/local_object_storage/engine/engine_test.go index a81b905c0..9095a0cae 100644 --- a/pkg/local_object_storage/engine/engine_test.go +++ b/pkg/local_object_storage/engine/engine_test.go @@ -11,6 +11,7 @@ import ( cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id" objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object" "github.com/nspcc-dev/neofs-api-go/pkg/owner" + ownertest "github.com/nspcc-dev/neofs-api-go/pkg/owner/test" "github.com/nspcc-dev/neofs-node/pkg/core/object" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor" meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase" @@ -79,9 +80,6 @@ func generateRawObjectWithCID(t *testing.T, cid *cid.ID) *object.RawObject { w, err := owner.NEO3WalletFromPublicKey(&test.DecodeKey(-1).PublicKey) require.NoError(t, err) - ownerID := owner.NewID() - ownerID.SetNeo3Wallet(w) - csum := new(pkg.Checksum) csum.SetSHA256(sha256.Sum256(w.Bytes())) @@ -90,7 +88,7 @@ func generateRawObjectWithCID(t *testing.T, cid *cid.ID) *object.RawObject { obj := object.NewRaw() obj.SetID(testOID()) - obj.SetOwnerID(ownerID) + obj.SetOwnerID(ownertest.Generate()) obj.SetContainerID(cid) obj.SetVersion(version) obj.SetPayloadChecksum(csum) diff --git a/pkg/local_object_storage/metabase/db_test.go b/pkg/local_object_storage/metabase/db_test.go index 9a5b48a50..bf30cbbe3 100644 --- a/pkg/local_object_storage/metabase/db_test.go +++ b/pkg/local_object_storage/metabase/db_test.go @@ -11,6 +11,7 @@ import ( cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test" objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object" "github.com/nspcc-dev/neofs-api-go/pkg/owner" + ownertest "github.com/nspcc-dev/neofs-api-go/pkg/owner/test" "github.com/nspcc-dev/neofs-node/pkg/core/object" meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase" "github.com/nspcc-dev/neofs-node/pkg/util/test" @@ -70,9 +71,6 @@ func generateRawObjectWithCID(t *testing.T, cid *cid.ID) *object.RawObject { w, err := owner.NEO3WalletFromPublicKey(&test.DecodeKey(-1).PublicKey) require.NoError(t, err) - ownerID := owner.NewID() - ownerID.SetNeo3Wallet(w) - csum := new(pkg.Checksum) csum.SetSHA256(sha256.Sum256(w.Bytes())) @@ -81,7 +79,7 @@ func generateRawObjectWithCID(t *testing.T, cid *cid.ID) *object.RawObject { obj := object.NewRaw() obj.SetID(testOID()) - obj.SetOwnerID(ownerID) + obj.SetOwnerID(ownertest.Generate()) obj.SetContainerID(cid) obj.SetVersion(version) obj.SetPayloadChecksum(csum) diff --git a/pkg/local_object_storage/shard/shard_test.go b/pkg/local_object_storage/shard/shard_test.go index 4cbf5877b..a5bfb1b9a 100644 --- a/pkg/local_object_storage/shard/shard_test.go +++ b/pkg/local_object_storage/shard/shard_test.go @@ -12,6 +12,7 @@ import ( cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test" objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object" "github.com/nspcc-dev/neofs-api-go/pkg/owner" + ownertest "github.com/nspcc-dev/neofs-api-go/pkg/owner/test" "github.com/nspcc-dev/neofs-node/pkg/core/object" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor" meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase" @@ -73,9 +74,6 @@ func generateRawObjectWithCID(t *testing.T, cid *cid.ID) *object.RawObject { w, err := owner.NEO3WalletFromPublicKey(&test.DecodeKey(-1).PublicKey) require.NoError(t, err) - ownerID := owner.NewID() - ownerID.SetNeo3Wallet(w) - csum := new(pkg.Checksum) csum.SetSHA256(sha256.Sum256(w.Bytes())) @@ -84,7 +82,7 @@ func generateRawObjectWithCID(t *testing.T, cid *cid.ID) *object.RawObject { obj := object.NewRaw() obj.SetID(generateOID()) - obj.SetOwnerID(ownerID) + obj.SetOwnerID(ownertest.Generate()) obj.SetContainerID(cid) obj.SetVersion(version) obj.SetPayloadChecksum(csum)