forked from TrueCloudLab/frostfs-node
[#64] core/object: Claim TombstoneContent in tombstone payload
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
21bdc82fb5
commit
33ca88f85f
2 changed files with 11 additions and 6 deletions
|
@ -89,13 +89,15 @@ func (v *FormatValidator) ValidateContent(t object.Type, payload []byte) error {
|
||||||
return errors.Errorf("(%T) empty payload in tombstone", v)
|
return errors.Errorf("(%T) empty payload in tombstone", v)
|
||||||
}
|
}
|
||||||
|
|
||||||
addr, err := object.AddressFromBytes(payload)
|
content, err := TombstoneContentFromBytes(payload)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "(%T) could not parse object address from tombstone", v)
|
return errors.Wrapf(err, "(%T) could not parse tombstone content", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if addr.GetContainerID() == nil || addr.GetObjectID() == nil {
|
for _, addr := range content.GetAddressList() {
|
||||||
return errors.Errorf("(%T) empty address reference in tombstone", v)
|
if addr.GetContainerID() == nil || addr.GetObjectID() == nil {
|
||||||
|
return errors.Errorf("(%T) empty address reference in tombstone", v)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,10 @@ func TestFormatValidator_Validate(t *testing.T) {
|
||||||
|
|
||||||
addr := object.NewAddress()
|
addr := object.NewAddress()
|
||||||
|
|
||||||
data, err := addr.ToV2().StableMarshal(nil)
|
content := NewTombstoneContent()
|
||||||
|
content.SetAddressList(addr)
|
||||||
|
|
||||||
|
data, err := content.MarshalBinary()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
require.Error(t, v.ValidateContent(object.TypeTombstone, data))
|
require.Error(t, v.ValidateContent(object.TypeTombstone, data))
|
||||||
|
@ -117,7 +120,7 @@ func TestFormatValidator_Validate(t *testing.T) {
|
||||||
addr.SetContainerID(testContainerID(t))
|
addr.SetContainerID(testContainerID(t))
|
||||||
addr.SetObjectID(testObjectID(t))
|
addr.SetObjectID(testObjectID(t))
|
||||||
|
|
||||||
data, err = addr.ToV2().StableMarshal(nil)
|
data, err = content.MarshalBinary()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
require.NoError(t, v.ValidateContent(object.TypeTombstone, data))
|
require.NoError(t, v.ValidateContent(object.TypeTombstone, data))
|
||||||
|
|
Loading…
Reference in a new issue