forked from TrueCloudLab/frostfs-node
[#633] object: Disallow empty attribute values
Values of object attributes must not be empty according to NeoFS specification. Make `FormatValidator.Validate` method to return an error if at least one attribute has empty value. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
01dd17e30a
commit
25391111ad
2 changed files with 21 additions and 2 deletions
|
@ -222,7 +222,7 @@ func TestFormatValidator_Validate(t *testing.T) {
|
|||
|
||||
t.Run("attributes", func(t *testing.T) {
|
||||
t.Run("duplication", func(t *testing.T) {
|
||||
obj := blankValidObject(t, ownerKey)
|
||||
obj := blankValidObject(t, &ownerKey.PrivateKey)
|
||||
|
||||
a1 := object.NewAttribute()
|
||||
a1.SetKey("key1")
|
||||
|
@ -242,5 +242,17 @@ func TestFormatValidator_Validate(t *testing.T) {
|
|||
err = v.checkAttributes(obj.Object())
|
||||
require.Equal(t, errDuplAttr, err)
|
||||
})
|
||||
|
||||
t.Run("empty value", func(t *testing.T) {
|
||||
obj := blankValidObject(t, &ownerKey.PrivateKey)
|
||||
|
||||
a := object.NewAttribute()
|
||||
a.SetKey("key")
|
||||
|
||||
obj.SetAttributes(a)
|
||||
|
||||
err := v.checkAttributes(obj.Object())
|
||||
require.Equal(t, errEmptyAttrVal, err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue