2022-03-05 08:53:01 +00:00
|
|
|
package layer
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
2023-03-07 14:38:08 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api/data"
|
2024-12-10 08:03:30 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/object"
|
2022-03-05 08:53:01 +00:00
|
|
|
"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-08-16 08:19:56 +00:00
|
|
|
p := &PutLockInfoParams{
|
2024-04-10 06:41:07 +00:00
|
|
|
ObjVersion: &data.ObjectVersion{
|
2022-08-16 08:19:56 +00:00
|
|
|
BktInfo: tc.bktInfo,
|
|
|
|
ObjectName: obj.Name,
|
|
|
|
VersionID: obj.VersionID(),
|
|
|
|
},
|
|
|
|
NewLock: &data.ObjectLock{
|
|
|
|
Retention: &data.RetentionLock{
|
|
|
|
Until: time.Now(),
|
|
|
|
},
|
2022-03-05 08:53:01 +00:00
|
|
|
},
|
2023-04-24 23:49:12 +00:00
|
|
|
CopiesNumbers: []uint32{0},
|
2022-05-26 13:11:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-16 08:19:56 +00:00
|
|
|
err = tc.layer.PutLockInfo(tc.ctx, p)
|
2022-05-26 13:11:14 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
2022-08-16 08:19:56 +00:00
|
|
|
foundLock, err := tc.layer.GetLockInfo(tc.ctx, p.ObjVersion)
|
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() {
|
2023-03-22 06:53:14 +00:00
|
|
|
if attr.Key() == object.SysAttributeExpEpoch {
|
2022-03-17 14:03:06 +00:00
|
|
|
expEpoch = true
|
2022-03-05 08:53:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-22 06:53:14 +00:00
|
|
|
require.Truef(t, expEpoch, "system header __SYSTEM__EXPIRATION_EPOCH presence")
|
2022-03-05 08:53:01 +00:00
|
|
|
}
|