[#195] Set tick attribute to lock objects

Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
Denis Kirillov 2022-03-05 11:53:01 +03:00 committed by Angira Kekteeva
parent 4c3c4b6bee
commit 4a67e4b311
8 changed files with 122 additions and 43 deletions

47
api/layer/locking_test.go Normal file
View file

@ -0,0 +1,47 @@
package layer
import (
"testing"
"time"
"github.com/nspcc-dev/neofs-s3-gw/api/data"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
"github.com/stretchr/testify/require"
)
func TestObjectLockAttributes(t *testing.T) {
tc := prepareContext(t)
err := tc.layer.PutBucketSettings(tc.ctx, &PutSettingsParams{
BktInfo: tc.bktInfo,
Settings: &data.BucketSettings{VersioningEnabled: true},
})
require.NoError(t, err)
obj := tc.putObject([]byte("content obj1 v1"))
_, err = tc.layer.PutSystemObject(tc.ctx, &PutSystemObjectParams{
BktInfo: tc.bktInfo,
ObjName: obj.RetentionObject(),
Metadata: make(map[string]string),
Lock: &data.ObjectLock{
Until: time.Now(),
Objects: []oid.ID{*obj.ID},
},
})
require.NoError(t, err)
lockObj := tc.getSystemObject(obj.RetentionObject())
require.NotNil(t, lockObj)
tickTopic, tickEpoch := false, false
for _, attr := range lockObj.Attributes() {
if attr.Key() == AttributeSysTickEpoch {
tickEpoch = true
} else if attr.Key() == AttributeSysTickTopic {
tickTopic = true
}
}
require.Truef(t, tickTopic, "system header __NEOFS__TICK_TOPIC presence")
require.Truef(t, tickEpoch, "system header __NEOFS__TICK_EPOCH presence")
}