2022-03-05 08:53:01 +00:00
|
|
|
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(),
|
2022-05-25 17:25:43 +00:00
|
|
|
Objects: []oid.ID{obj.ID},
|
2022-03-05 08:53:01 +00:00
|
|
|
},
|
|
|
|
})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
lockObj := tc.getSystemObject(obj.RetentionObject())
|
|
|
|
require.NotNil(t, lockObj)
|
|
|
|
|
2022-03-17 14:03:06 +00:00
|
|
|
expEpoch := false
|
2022-03-05 08:53:01 +00:00
|
|
|
for _, attr := range lockObj.Attributes() {
|
2022-03-17 14:03:06 +00:00
|
|
|
if attr.Key() == AttributeExpirationEpoch {
|
|
|
|
expEpoch = true
|
2022-03-05 08:53:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-17 14:03:06 +00:00
|
|
|
require.Truef(t, expEpoch, "system header __NEOFS__EXPIRATION_EPOCH presence")
|
2022-03-05 08:53:01 +00:00
|
|
|
}
|