forked from TrueCloudLab/frostfs-node
[#80] core/object: Add SG-object format validation
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
f7ca4a8dce
commit
8c4e033db3
2 changed files with 44 additions and 0 deletions
|
@ -9,6 +9,7 @@ import (
|
|||
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
||||
"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/storagegroup"
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/token"
|
||||
crypto "github.com/nspcc-dev/neofs-crypto"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/util/test"
|
||||
|
@ -129,4 +130,30 @@ func TestFormatValidator_Validate(t *testing.T) {
|
|||
|
||||
require.NoError(t, v.ValidateContent(obj.Object()))
|
||||
})
|
||||
|
||||
t.Run("storage group content", func(t *testing.T) {
|
||||
obj := NewRaw()
|
||||
obj.SetType(object.TypeStorageGroup)
|
||||
|
||||
require.Error(t, v.ValidateContent(obj.Object()))
|
||||
|
||||
content := storagegroup.New()
|
||||
content.SetMembers([]*object.ID{nil})
|
||||
|
||||
data, err := content.Marshal()
|
||||
require.NoError(t, err)
|
||||
|
||||
obj.SetPayload(data)
|
||||
|
||||
require.Error(t, v.ValidateContent(obj.Object()))
|
||||
|
||||
content.SetMembers([]*object.ID{testObjectID(t)})
|
||||
|
||||
data, err = content.Marshal()
|
||||
require.NoError(t, err)
|
||||
|
||||
obj.SetPayload(data)
|
||||
|
||||
require.NoError(t, v.ValidateContent(obj.Object()))
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue