2021-03-12 12:57:23 +00:00
|
|
|
package objecttest
|
|
|
|
|
|
|
|
import (
|
2023-08-11 12:21:17 +00:00
|
|
|
"math/rand"
|
|
|
|
"time"
|
|
|
|
|
2023-03-07 10:38:56 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/object"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs"
|
|
|
|
refstest "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs/test"
|
|
|
|
sessiontest "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/session/test"
|
2021-03-12 12:57:23 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func GenerateShortHeader(empty bool) *object.ShortHeader {
|
|
|
|
m := new(object.ShortHeader)
|
|
|
|
|
|
|
|
if !empty {
|
|
|
|
m.SetObjectType(13)
|
|
|
|
m.SetCreationEpoch(100)
|
|
|
|
m.SetPayloadLength(12321)
|
2021-06-11 12:39:56 +00:00
|
|
|
m.SetOwnerID(refstest.GenerateOwnerID(false))
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m.SetVersion(refstest.GenerateVersion(empty))
|
|
|
|
m.SetHomomorphicHash(refstest.GenerateChecksum(empty))
|
|
|
|
m.SetPayloadHash(refstest.GenerateChecksum(empty))
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateAttribute(empty bool) *object.Attribute {
|
|
|
|
m := new(object.Attribute)
|
|
|
|
|
|
|
|
if !empty {
|
|
|
|
m.SetKey("object key")
|
|
|
|
m.SetValue("object value")
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2022-02-28 12:06:51 +00:00
|
|
|
func GenerateAttributes(empty bool) []object.Attribute {
|
|
|
|
var res []object.Attribute
|
2021-06-11 12:39:56 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if !empty {
|
|
|
|
res = append(res,
|
2022-02-28 12:06:51 +00:00
|
|
|
*GenerateAttribute(false),
|
|
|
|
*GenerateAttribute(false),
|
2021-03-12 12:57:23 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-06-11 12:39:56 +00:00
|
|
|
return res
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateSplitHeader(empty bool) *object.SplitHeader {
|
|
|
|
return generateSplitHeader(empty, true)
|
|
|
|
}
|
|
|
|
|
|
|
|
func generateSplitHeader(empty, withPar bool) *object.SplitHeader {
|
|
|
|
m := new(object.SplitHeader)
|
|
|
|
|
|
|
|
if !empty {
|
|
|
|
m.SetSplitID([]byte{1, 3, 5})
|
2021-06-11 12:39:56 +00:00
|
|
|
m.SetParent(refstest.GenerateObjectID(false))
|
|
|
|
m.SetPrevious(refstest.GenerateObjectID(false))
|
|
|
|
m.SetChildren(refstest.GenerateObjectIDs(false))
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m.SetParentSignature(refstest.GenerateSignature(empty))
|
|
|
|
|
|
|
|
if withPar {
|
2024-05-08 12:03:29 +00:00
|
|
|
m.SetParentHeader(GenerateHeaderWithSplitHeader(empty))
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2024-05-08 12:03:29 +00:00
|
|
|
func GenerateHeaderWithSplitHeader(empty bool) *object.Header {
|
|
|
|
m := generateHeader(empty)
|
|
|
|
m.SetSplit(generateSplitHeader(empty, false))
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateHeaderWithECHeader(empty bool) *object.Header {
|
|
|
|
m := generateHeader(empty)
|
|
|
|
m.SetEC(GenerateECHeader(empty))
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateECHeader(empty bool) *object.ECHeader {
|
|
|
|
ech := new(object.ECHeader)
|
|
|
|
|
|
|
|
if !empty {
|
|
|
|
ech.Parent = refstest.GenerateObjectID(empty)
|
|
|
|
ech.ParentSplitID = []byte{1, 2, 3}
|
2024-05-16 09:03:42 +00:00
|
|
|
ech.ParentSplitParentID = refstest.GenerateObjectID(empty)
|
2024-05-08 12:03:29 +00:00
|
|
|
ech.Index = 0
|
|
|
|
ech.Total = 2
|
|
|
|
ech.Header = []byte("chunk of ec-encoded parent header")
|
|
|
|
ech.HeaderLength = uint32(2 * len(ech.Header))
|
|
|
|
}
|
|
|
|
|
|
|
|
return ech
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
|
|
|
|
2024-05-08 12:03:29 +00:00
|
|
|
func generateHeader(empty bool) *object.Header {
|
2021-03-12 12:57:23 +00:00
|
|
|
m := new(object.Header)
|
|
|
|
|
|
|
|
if !empty {
|
|
|
|
m.SetPayloadLength(777)
|
|
|
|
m.SetCreationEpoch(432)
|
|
|
|
m.SetObjectType(111)
|
2021-06-11 12:39:56 +00:00
|
|
|
m.SetOwnerID(refstest.GenerateOwnerID(false))
|
|
|
|
m.SetContainerID(refstest.GenerateContainerID(false))
|
|
|
|
m.SetAttributes(GenerateAttributes(false))
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m.SetVersion(refstest.GenerateVersion(empty))
|
|
|
|
m.SetPayloadHash(refstest.GenerateChecksum(empty))
|
|
|
|
m.SetHomomorphicHash(refstest.GenerateChecksum(empty))
|
|
|
|
m.SetSessionToken(sessiontest.GenerateSessionToken(empty))
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateHeaderWithSignature(empty bool) *object.HeaderWithSignature {
|
|
|
|
m := new(object.HeaderWithSignature)
|
|
|
|
|
|
|
|
m.SetSignature(refstest.GenerateSignature(empty))
|
2024-05-08 12:03:29 +00:00
|
|
|
m.SetHeader(GenerateHeaderWithSplitHeader(empty))
|
2021-03-12 12:57:23 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateObject(empty bool) *object.Object {
|
|
|
|
m := new(object.Object)
|
|
|
|
|
|
|
|
if !empty {
|
|
|
|
m.SetPayload([]byte{7, 8, 9})
|
2021-06-11 12:39:56 +00:00
|
|
|
m.SetObjectID(refstest.GenerateObjectID(false))
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m.SetSignature(refstest.GenerateSignature(empty))
|
2024-05-08 12:03:29 +00:00
|
|
|
m.SetHeader(GenerateHeaderWithSplitHeader(empty))
|
2021-03-12 12:57:23 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateSplitInfo(empty bool) *object.SplitInfo {
|
|
|
|
m := new(object.SplitInfo)
|
|
|
|
|
|
|
|
if !empty {
|
|
|
|
m.SetSplitID([]byte("splitID"))
|
2021-06-11 12:39:56 +00:00
|
|
|
m.SetLastPart(refstest.GenerateObjectID(false))
|
|
|
|
m.SetLink(refstest.GenerateObjectID(false))
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2024-03-19 06:55:23 +00:00
|
|
|
func GenerateECInfo(empty bool) *object.ECInfo {
|
|
|
|
m := new(object.ECInfo)
|
|
|
|
|
|
|
|
if !empty {
|
|
|
|
m.Chunks = make([]object.ECChunk, 2)
|
|
|
|
for i := range m.Chunks {
|
|
|
|
m.Chunks[i] = *GenerateECChunk(false)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateECChunk(empty bool) *object.ECChunk {
|
|
|
|
m := new(object.ECChunk)
|
|
|
|
|
|
|
|
if !empty {
|
|
|
|
m.ID = *refstest.GenerateObjectID(false)
|
|
|
|
m.Index = 4
|
|
|
|
m.Total = 7
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func GenerateGetRequestBody(empty bool) *object.GetRequestBody {
|
|
|
|
m := new(object.GetRequestBody)
|
|
|
|
|
|
|
|
if !empty {
|
|
|
|
m.SetRaw(true)
|
2021-06-11 12:39:56 +00:00
|
|
|
m.SetAddress(refstest.GenerateAddress(false))
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateGetRequest(empty bool) *object.GetRequest {
|
|
|
|
m := new(object.GetRequest)
|
|
|
|
|
2021-06-11 12:39:56 +00:00
|
|
|
if !empty {
|
|
|
|
m.SetBody(GenerateGetRequestBody(false))
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetMetaHeader(sessiontest.GenerateRequestMetaHeader(empty))
|
|
|
|
m.SetVerificationHeader(sessiontest.GenerateRequestVerificationHeader(empty))
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateGetObjectPartInit(empty bool) *object.GetObjectPartInit {
|
|
|
|
m := new(object.GetObjectPartInit)
|
|
|
|
|
2021-06-11 12:39:56 +00:00
|
|
|
if !empty {
|
|
|
|
m.SetObjectID(refstest.GenerateObjectID(false))
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetSignature(refstest.GenerateSignature(empty))
|
2024-05-08 12:03:29 +00:00
|
|
|
m.SetHeader(GenerateHeaderWithSplitHeader(empty))
|
2021-03-12 12:57:23 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateGetObjectPartChunk(empty bool) *object.GetObjectPartChunk {
|
|
|
|
m := new(object.GetObjectPartChunk)
|
|
|
|
|
|
|
|
if !empty {
|
|
|
|
m.SetChunk([]byte("get chunk"))
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateGetResponseBody(empty bool) *object.GetResponseBody {
|
|
|
|
m := new(object.GetResponseBody)
|
|
|
|
|
2021-06-11 12:39:56 +00:00
|
|
|
if !empty {
|
2023-08-11 12:21:17 +00:00
|
|
|
switch randomInt(3) {
|
2022-05-30 18:13:35 +00:00
|
|
|
case 0:
|
|
|
|
m.SetObjectPart(GenerateGetObjectPartInit(false))
|
|
|
|
case 1:
|
|
|
|
m.SetObjectPart(GenerateGetObjectPartChunk(false))
|
|
|
|
case 2:
|
|
|
|
m.SetObjectPart(GenerateSplitInfo(false))
|
|
|
|
}
|
2021-06-11 12:39:56 +00:00
|
|
|
}
|
2021-03-12 12:57:23 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateGetResponse(empty bool) *object.GetResponse {
|
|
|
|
m := new(object.GetResponse)
|
|
|
|
|
2021-06-11 12:39:56 +00:00
|
|
|
if !empty {
|
|
|
|
m.SetBody(GenerateGetResponseBody(false))
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetMetaHeader(sessiontest.GenerateResponseMetaHeader(empty))
|
|
|
|
m.SetVerificationHeader(sessiontest.GenerateResponseVerificationHeader(empty))
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GeneratePutObjectPartInit(empty bool) *object.PutObjectPartInit {
|
|
|
|
m := new(object.PutObjectPartInit)
|
|
|
|
|
|
|
|
if !empty {
|
2023-04-11 07:37:11 +00:00
|
|
|
m.SetCopiesNumber([]uint32{234})
|
2021-06-11 12:39:56 +00:00
|
|
|
m.SetObjectID(refstest.GenerateObjectID(false))
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m.SetSignature(refstest.GenerateSignature(empty))
|
2024-05-08 12:03:29 +00:00
|
|
|
m.SetHeader(GenerateHeaderWithSplitHeader(empty))
|
2021-03-12 12:57:23 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GeneratePutObjectPartChunk(empty bool) *object.PutObjectPartChunk {
|
|
|
|
m := new(object.PutObjectPartChunk)
|
|
|
|
|
|
|
|
if !empty {
|
|
|
|
m.SetChunk([]byte("put chunk"))
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GeneratePutRequestBody(empty bool) *object.PutRequestBody {
|
|
|
|
m := new(object.PutRequestBody)
|
|
|
|
|
2021-06-11 12:39:56 +00:00
|
|
|
if !empty {
|
2023-08-11 12:21:17 +00:00
|
|
|
switch randomInt(2) {
|
2022-05-30 18:13:35 +00:00
|
|
|
case 0:
|
|
|
|
m.SetObjectPart(GeneratePutObjectPartInit(false))
|
|
|
|
case 1:
|
|
|
|
m.SetObjectPart(GeneratePutObjectPartChunk(false))
|
|
|
|
}
|
2021-06-11 12:39:56 +00:00
|
|
|
}
|
2021-03-12 12:57:23 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GeneratePutRequest(empty bool) *object.PutRequest {
|
|
|
|
m := new(object.PutRequest)
|
|
|
|
|
2021-06-11 12:39:56 +00:00
|
|
|
if !empty {
|
|
|
|
m.SetBody(GeneratePutRequestBody(false))
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetMetaHeader(sessiontest.GenerateRequestMetaHeader(empty))
|
|
|
|
m.SetVerificationHeader(sessiontest.GenerateRequestVerificationHeader(empty))
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GeneratePutResponseBody(empty bool) *object.PutResponseBody {
|
|
|
|
m := new(object.PutResponseBody)
|
|
|
|
|
2021-06-11 12:39:56 +00:00
|
|
|
if !empty {
|
|
|
|
m.SetObjectID(refstest.GenerateObjectID(false))
|
|
|
|
}
|
2021-03-12 12:57:23 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GeneratePutResponse(empty bool) *object.PutResponse {
|
|
|
|
m := new(object.PutResponse)
|
|
|
|
|
2021-06-11 12:39:56 +00:00
|
|
|
if !empty {
|
|
|
|
m.SetBody(GeneratePutResponseBody(false))
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetMetaHeader(sessiontest.GenerateResponseMetaHeader(empty))
|
|
|
|
m.SetVerificationHeader(sessiontest.GenerateResponseVerificationHeader(empty))
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateDeleteRequestBody(empty bool) *object.DeleteRequestBody {
|
|
|
|
m := new(object.DeleteRequestBody)
|
|
|
|
|
2021-06-11 12:39:56 +00:00
|
|
|
if !empty {
|
|
|
|
m.SetAddress(refstest.GenerateAddress(false))
|
|
|
|
}
|
2021-03-12 12:57:23 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateDeleteRequest(empty bool) *object.DeleteRequest {
|
|
|
|
m := new(object.DeleteRequest)
|
|
|
|
|
2021-06-11 12:39:56 +00:00
|
|
|
if !empty {
|
|
|
|
m.SetBody(GenerateDeleteRequestBody(false))
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetMetaHeader(sessiontest.GenerateRequestMetaHeader(empty))
|
|
|
|
m.SetVerificationHeader(sessiontest.GenerateRequestVerificationHeader(empty))
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateDeleteResponseBody(empty bool) *object.DeleteResponseBody {
|
|
|
|
m := new(object.DeleteResponseBody)
|
|
|
|
|
2021-06-11 12:39:56 +00:00
|
|
|
if !empty {
|
|
|
|
m.SetTombstone(refstest.GenerateAddress(false))
|
|
|
|
}
|
2021-03-12 12:57:23 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateDeleteResponse(empty bool) *object.DeleteResponse {
|
|
|
|
m := new(object.DeleteResponse)
|
|
|
|
|
2021-06-11 12:39:56 +00:00
|
|
|
if !empty {
|
|
|
|
m.SetBody(GenerateDeleteResponseBody(false))
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetMetaHeader(sessiontest.GenerateResponseMetaHeader(empty))
|
|
|
|
m.SetVerificationHeader(sessiontest.GenerateResponseVerificationHeader(empty))
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateHeadRequestBody(empty bool) *object.HeadRequestBody {
|
|
|
|
m := new(object.HeadRequestBody)
|
|
|
|
|
|
|
|
if !empty {
|
|
|
|
m.SetRaw(true)
|
|
|
|
m.SetMainOnly(true)
|
2021-06-11 12:39:56 +00:00
|
|
|
m.SetAddress(refstest.GenerateAddress(false))
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateHeadRequest(empty bool) *object.HeadRequest {
|
|
|
|
m := new(object.HeadRequest)
|
|
|
|
|
2021-06-11 12:39:56 +00:00
|
|
|
if !empty {
|
|
|
|
m.SetBody(GenerateHeadRequestBody(false))
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetMetaHeader(sessiontest.GenerateRequestMetaHeader(empty))
|
|
|
|
m.SetVerificationHeader(sessiontest.GenerateRequestVerificationHeader(empty))
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateHeadResponseBody(empty bool) *object.HeadResponseBody {
|
|
|
|
m := new(object.HeadResponseBody)
|
|
|
|
|
2021-06-11 12:39:56 +00:00
|
|
|
if !empty {
|
2023-08-11 12:21:17 +00:00
|
|
|
switch randomInt(3) {
|
2022-05-30 18:13:35 +00:00
|
|
|
case 0:
|
|
|
|
m.SetHeaderPart(GenerateHeaderWithSignature(false))
|
|
|
|
case 1:
|
|
|
|
m.SetHeaderPart(GenerateShortHeader(false))
|
|
|
|
case 2:
|
|
|
|
m.SetHeaderPart(GenerateSplitInfo(false))
|
|
|
|
}
|
2021-06-11 12:39:56 +00:00
|
|
|
}
|
2021-03-12 12:57:23 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateHeadResponse(empty bool) *object.HeadResponse {
|
|
|
|
m := new(object.HeadResponse)
|
|
|
|
|
2021-06-11 12:39:56 +00:00
|
|
|
if !empty {
|
|
|
|
m.SetBody(GenerateHeadResponseBody(false))
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetMetaHeader(sessiontest.GenerateResponseMetaHeader(empty))
|
|
|
|
m.SetVerificationHeader(sessiontest.GenerateResponseVerificationHeader(empty))
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateSearchFilter(empty bool) *object.SearchFilter {
|
|
|
|
m := new(object.SearchFilter)
|
|
|
|
|
|
|
|
if !empty {
|
|
|
|
m.SetKey("search filter key")
|
|
|
|
m.SetValue("search filter val")
|
|
|
|
m.SetMatchType(987)
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2022-03-02 08:03:56 +00:00
|
|
|
func GenerateSearchFilters(empty bool) []object.SearchFilter {
|
|
|
|
var res []object.SearchFilter
|
2021-06-11 12:39:56 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if !empty {
|
|
|
|
res = append(res,
|
2022-03-02 08:03:56 +00:00
|
|
|
*GenerateSearchFilter(false),
|
|
|
|
*GenerateSearchFilter(false),
|
2021-03-12 12:57:23 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-06-11 12:39:56 +00:00
|
|
|
return res
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateSearchRequestBody(empty bool) *object.SearchRequestBody {
|
|
|
|
m := new(object.SearchRequestBody)
|
|
|
|
|
|
|
|
if !empty {
|
|
|
|
m.SetVersion(555)
|
2021-06-11 12:39:56 +00:00
|
|
|
m.SetContainerID(refstest.GenerateContainerID(false))
|
|
|
|
m.SetFilters(GenerateSearchFilters(false))
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateSearchRequest(empty bool) *object.SearchRequest {
|
|
|
|
m := new(object.SearchRequest)
|
|
|
|
|
2021-06-11 12:39:56 +00:00
|
|
|
if !empty {
|
|
|
|
m.SetBody(GenerateSearchRequestBody(false))
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetMetaHeader(sessiontest.GenerateRequestMetaHeader(empty))
|
|
|
|
m.SetVerificationHeader(sessiontest.GenerateRequestVerificationHeader(empty))
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateSearchResponseBody(empty bool) *object.SearchResponseBody {
|
|
|
|
m := new(object.SearchResponseBody)
|
|
|
|
|
2021-06-11 12:39:56 +00:00
|
|
|
if !empty {
|
|
|
|
m.SetIDList(refstest.GenerateObjectIDs(false))
|
|
|
|
}
|
2021-03-12 12:57:23 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateSearchResponse(empty bool) *object.SearchResponse {
|
|
|
|
m := new(object.SearchResponse)
|
|
|
|
|
2021-06-11 12:39:56 +00:00
|
|
|
if !empty {
|
|
|
|
m.SetBody(GenerateSearchResponseBody(false))
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetMetaHeader(sessiontest.GenerateResponseMetaHeader(empty))
|
|
|
|
m.SetVerificationHeader(sessiontest.GenerateResponseVerificationHeader(empty))
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateRange(empty bool) *object.Range {
|
|
|
|
m := new(object.Range)
|
|
|
|
|
|
|
|
if !empty {
|
|
|
|
m.SetLength(11)
|
|
|
|
m.SetOffset(22)
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2022-03-02 08:03:56 +00:00
|
|
|
func GenerateRanges(empty bool) []object.Range {
|
|
|
|
var res []object.Range
|
2021-06-11 12:39:56 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if !empty {
|
|
|
|
res = append(res,
|
2022-03-02 08:03:56 +00:00
|
|
|
*GenerateRange(false),
|
|
|
|
*GenerateRange(false),
|
2021-03-12 12:57:23 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-06-11 12:39:56 +00:00
|
|
|
return res
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateGetRangeRequestBody(empty bool) *object.GetRangeRequestBody {
|
|
|
|
m := new(object.GetRangeRequestBody)
|
|
|
|
|
|
|
|
if !empty {
|
|
|
|
m.SetRaw(true)
|
2021-06-11 12:39:56 +00:00
|
|
|
m.SetAddress(refstest.GenerateAddress(empty))
|
|
|
|
m.SetRange(GenerateRange(empty))
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateGetRangeRequest(empty bool) *object.GetRangeRequest {
|
|
|
|
m := new(object.GetRangeRequest)
|
|
|
|
|
2021-06-11 12:39:56 +00:00
|
|
|
if !empty {
|
|
|
|
m.SetBody(GenerateGetRangeRequestBody(false))
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetMetaHeader(sessiontest.GenerateRequestMetaHeader(empty))
|
|
|
|
m.SetVerificationHeader(sessiontest.GenerateRequestVerificationHeader(empty))
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateGetRangePartChunk(empty bool) *object.GetRangePartChunk {
|
|
|
|
m := new(object.GetRangePartChunk)
|
|
|
|
|
|
|
|
if !empty {
|
|
|
|
m.SetChunk([]byte("get range chunk"))
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateGetRangeResponseBody(empty bool) *object.GetRangeResponseBody {
|
|
|
|
m := new(object.GetRangeResponseBody)
|
|
|
|
|
2021-06-11 12:39:56 +00:00
|
|
|
if !empty {
|
2023-08-11 12:21:17 +00:00
|
|
|
switch randomInt(2) {
|
2022-05-30 18:13:35 +00:00
|
|
|
case 0:
|
|
|
|
m.SetRangePart(GenerateGetRangePartChunk(false))
|
|
|
|
case 1:
|
|
|
|
m.SetRangePart(GenerateSplitInfo(false))
|
|
|
|
}
|
2021-06-11 12:39:56 +00:00
|
|
|
}
|
2021-03-12 12:57:23 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateGetRangeResponse(empty bool) *object.GetRangeResponse {
|
|
|
|
m := new(object.GetRangeResponse)
|
|
|
|
|
2021-06-11 12:39:56 +00:00
|
|
|
if !empty {
|
|
|
|
m.SetBody(GenerateGetRangeResponseBody(false))
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetMetaHeader(sessiontest.GenerateResponseMetaHeader(empty))
|
|
|
|
m.SetVerificationHeader(sessiontest.GenerateResponseVerificationHeader(empty))
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateGetRangeHashRequestBody(empty bool) *object.GetRangeHashRequestBody {
|
|
|
|
m := new(object.GetRangeHashRequestBody)
|
|
|
|
|
|
|
|
if !empty {
|
|
|
|
m.SetSalt([]byte("range hash salt"))
|
|
|
|
m.SetType(455)
|
2021-06-11 12:39:56 +00:00
|
|
|
m.SetAddress(refstest.GenerateAddress(false))
|
|
|
|
m.SetRanges(GenerateRanges(false))
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateGetRangeHashRequest(empty bool) *object.GetRangeHashRequest {
|
|
|
|
m := new(object.GetRangeHashRequest)
|
|
|
|
|
2021-06-11 12:39:56 +00:00
|
|
|
if !empty {
|
|
|
|
m.SetBody(GenerateGetRangeHashRequestBody(false))
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetMetaHeader(sessiontest.GenerateRequestMetaHeader(empty))
|
|
|
|
m.SetVerificationHeader(sessiontest.GenerateRequestVerificationHeader(empty))
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateGetRangeHashResponseBody(empty bool) *object.GetRangeHashResponseBody {
|
|
|
|
m := new(object.GetRangeHashResponseBody)
|
|
|
|
|
|
|
|
if !empty {
|
|
|
|
m.SetType(678)
|
|
|
|
m.SetHashList([][]byte{{1}, {2}})
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateGetRangeHashResponse(empty bool) *object.GetRangeHashResponse {
|
|
|
|
m := new(object.GetRangeHashResponse)
|
|
|
|
|
2021-06-11 12:39:56 +00:00
|
|
|
if !empty {
|
|
|
|
m.SetBody(GenerateGetRangeHashResponseBody(false))
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetMetaHeader(sessiontest.GenerateResponseMetaHeader(empty))
|
|
|
|
m.SetVerificationHeader(sessiontest.GenerateResponseVerificationHeader(empty))
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
2022-02-21 17:57:27 +00:00
|
|
|
|
|
|
|
func GenerateLock(empty bool) *object.Lock {
|
|
|
|
m := new(object.Lock)
|
|
|
|
|
|
|
|
if !empty {
|
|
|
|
m.SetMembers([]refs.ObjectID{
|
|
|
|
*refstest.GenerateObjectID(false),
|
|
|
|
*refstest.GenerateObjectID(false),
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
2023-06-30 12:00:51 +00:00
|
|
|
|
|
|
|
func GeneratePutSingleRequest(empty bool) *object.PutSingleRequest {
|
|
|
|
m := new(object.PutSingleRequest)
|
|
|
|
|
|
|
|
if !empty {
|
|
|
|
m.SetBody(GeneratePutSingleRequestBody(false))
|
|
|
|
}
|
|
|
|
|
|
|
|
m.SetMetaHeader(sessiontest.GenerateRequestMetaHeader(empty))
|
|
|
|
m.SetVerificationHeader(sessiontest.GenerateRequestVerificationHeader(empty))
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GeneratePutSingleRequestBody(empty bool) *object.PutSingleRequestBody {
|
|
|
|
b := new(object.PutSingleRequestBody)
|
|
|
|
if !empty {
|
|
|
|
b.SetObject(GenerateObject(empty))
|
|
|
|
b.SetCopiesNumber([]uint32{12345})
|
|
|
|
}
|
|
|
|
return b
|
|
|
|
}
|
2023-06-30 13:05:37 +00:00
|
|
|
|
|
|
|
func GeneratePutSingleResponse(empty bool) *object.PutSingleResponse {
|
|
|
|
m := new(object.PutSingleResponse)
|
|
|
|
if !empty {
|
|
|
|
m.SetBody(new(object.PutSingleResponseBody))
|
|
|
|
}
|
|
|
|
m.SetMetaHeader(sessiontest.GenerateResponseMetaHeader(empty))
|
|
|
|
m.SetVerificationHeader(sessiontest.GenerateResponseVerificationHeader(empty))
|
|
|
|
return m
|
|
|
|
}
|
2023-08-11 12:21:17 +00:00
|
|
|
|
|
|
|
func randomInt(n int) int {
|
|
|
|
return rand.New(rand.NewSource(time.Now().UnixNano())).Intn(n)
|
|
|
|
}
|