2022-03-05 08:53:01 +00:00
|
|
|
package layer
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/nspcc-dev/neofs-s3-gw/api/data"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestObjectLockAttributes(t *testing.T) {
|
|
|
|
tc := prepareContext(t)
|
|
|
|
err := tc.layer.PutBucketSettings(tc.ctx, &PutSettingsParams{
|
|
|
|
BktInfo: tc.bktInfo,
|
2022-07-20 10:30:19 +00:00
|
|
|
Settings: &data.BucketSettings{Versioning: data.VersioningEnabled},
|
2022-03-05 08:53:01 +00:00
|
|
|
})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
obj := tc.putObject([]byte("content obj1 v1"))
|
|
|
|
|
2022-05-26 13:11:14 +00:00
|
|
|
p := &ObjectVersion{
|
|
|
|
BktInfo: tc.bktInfo,
|
|
|
|
ObjectName: obj.Name,
|
|
|
|
VersionID: obj.Version(),
|
|
|
|
}
|
|
|
|
|
|
|
|
lock := &data.ObjectLock{
|
|
|
|
Retention: &data.RetentionLock{
|
|
|
|
Until: time.Now(),
|
2022-03-05 08:53:01 +00:00
|
|
|
},
|
2022-05-26 13:11:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
err = tc.layer.PutLockInfo(tc.ctx, p, lock)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
foundLock, err := tc.layer.GetLockInfo(tc.ctx, p)
|
2022-03-05 08:53:01 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
2022-06-27 09:33:36 +00:00
|
|
|
lockObj := tc.getObjectByID(foundLock.Retention())
|
2022-03-05 08:53:01 +00:00
|
|
|
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
|
|
|
}
|