[#570] *: Use generator of test owner IDs from API Go lib

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-05-31 14:34:39 +03:00 committed by Leonard Lyubich
parent 3e1463cc76
commit d34de558f0
4 changed files with 14 additions and 17 deletions

View file

@ -11,10 +11,9 @@ import (
cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test" 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/object"
"github.com/nspcc-dev/neofs-api-go/pkg/owner" "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" "github.com/nspcc-dev/neofs-api-go/pkg/storagegroup"
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object" 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/nspcc-dev/neofs-node/pkg/util/test"
"github.com/stretchr/testify/require" "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) { t.Run("correct w/ session token", func(t *testing.T) {
tok := session.NewToken() w, err := owner.NEO3WalletFromPublicKey(&ownerKey.PublicKey)
tok.SetSessionKey(crypto.MarshalPublicKey(&ownerKey.PublicKey)) require.NoError(t, err)
tok := sessiontest.Generate()
tok.SetOwnerID(owner.NewIDFromNeo3Wallet(w))
obj := NewRaw() obj := NewRaw()
obj.SetContainerID(cidtest.Generate()) obj.SetContainerID(cidtest.Generate())
obj.SetSessionToken(tok) obj.SetSessionToken(sessiontest.Generate())
obj.SetOwnerID(tok.OwnerID())
require.NoError(t, object.SetIDWithSignature(ownerKey, obj.SDK())) require.NoError(t, object.SetIDWithSignature(ownerKey, obj.SDK()))

View file

@ -11,6 +11,7 @@ import (
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id" cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object" objectSDK "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/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/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase" 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) w, err := owner.NEO3WalletFromPublicKey(&test.DecodeKey(-1).PublicKey)
require.NoError(t, err) require.NoError(t, err)
ownerID := owner.NewID()
ownerID.SetNeo3Wallet(w)
csum := new(pkg.Checksum) csum := new(pkg.Checksum)
csum.SetSHA256(sha256.Sum256(w.Bytes())) csum.SetSHA256(sha256.Sum256(w.Bytes()))
@ -90,7 +88,7 @@ func generateRawObjectWithCID(t *testing.T, cid *cid.ID) *object.RawObject {
obj := object.NewRaw() obj := object.NewRaw()
obj.SetID(testOID()) obj.SetID(testOID())
obj.SetOwnerID(ownerID) obj.SetOwnerID(ownertest.Generate())
obj.SetContainerID(cid) obj.SetContainerID(cid)
obj.SetVersion(version) obj.SetVersion(version)
obj.SetPayloadChecksum(csum) obj.SetPayloadChecksum(csum)

View file

@ -11,6 +11,7 @@ import (
cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test" cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test"
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object" objectSDK "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/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/core/object"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase" meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
"github.com/nspcc-dev/neofs-node/pkg/util/test" "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) w, err := owner.NEO3WalletFromPublicKey(&test.DecodeKey(-1).PublicKey)
require.NoError(t, err) require.NoError(t, err)
ownerID := owner.NewID()
ownerID.SetNeo3Wallet(w)
csum := new(pkg.Checksum) csum := new(pkg.Checksum)
csum.SetSHA256(sha256.Sum256(w.Bytes())) csum.SetSHA256(sha256.Sum256(w.Bytes()))
@ -81,7 +79,7 @@ func generateRawObjectWithCID(t *testing.T, cid *cid.ID) *object.RawObject {
obj := object.NewRaw() obj := object.NewRaw()
obj.SetID(testOID()) obj.SetID(testOID())
obj.SetOwnerID(ownerID) obj.SetOwnerID(ownertest.Generate())
obj.SetContainerID(cid) obj.SetContainerID(cid)
obj.SetVersion(version) obj.SetVersion(version)
obj.SetPayloadChecksum(csum) obj.SetPayloadChecksum(csum)

View file

@ -12,6 +12,7 @@ import (
cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test" cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test"
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object" objectSDK "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/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/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase" 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) w, err := owner.NEO3WalletFromPublicKey(&test.DecodeKey(-1).PublicKey)
require.NoError(t, err) require.NoError(t, err)
ownerID := owner.NewID()
ownerID.SetNeo3Wallet(w)
csum := new(pkg.Checksum) csum := new(pkg.Checksum)
csum.SetSHA256(sha256.Sum256(w.Bytes())) csum.SetSHA256(sha256.Sum256(w.Bytes()))
@ -84,7 +82,7 @@ func generateRawObjectWithCID(t *testing.T, cid *cid.ID) *object.RawObject {
obj := object.NewRaw() obj := object.NewRaw()
obj.SetID(generateOID()) obj.SetID(generateOID())
obj.SetOwnerID(ownerID) obj.SetOwnerID(ownertest.Generate())
obj.SetContainerID(cid) obj.SetContainerID(cid)
obj.SetVersion(version) obj.SetVersion(version)
obj.SetPayloadChecksum(csum) obj.SetPayloadChecksum(csum)