2021-03-12 12:57:23 +00:00
|
|
|
package objecttest
|
|
|
|
|
|
|
|
import (
|
2023-03-07 10:38:56 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/internal/random"
|
|
|
|
"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 {
|
|
|
|
m.SetParentHeader(generateHeader(empty, false))
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateHeader(empty bool) *object.Header {
|
|
|
|
return generateHeader(empty, true)
|
|
|
|
}
|
|
|
|
|
|
|
|
func generateHeader(empty, withSplit bool) *object.Header {
|
|
|
|
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))
|
|
|
|
|
|
|
|
if withSplit {
|
|
|
|
m.SetSplit(generateSplitHeader(empty, false))
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateHeaderWithSignature(empty bool) *object.HeaderWithSignature {
|
|
|
|
m := new(object.HeaderWithSignature)
|
|
|
|
|
|
|
|
m.SetSignature(refstest.GenerateSignature(empty))
|
|
|
|
m.SetHeader(GenerateHeader(empty))
|
|
|
|
|
|
|
|
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))
|
|
|
|
m.SetHeader(GenerateHeader(empty))
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
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))
|
|
|
|
m.SetHeader(GenerateHeader(empty))
|
|
|
|
|
|
|
|
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 {
|
2022-05-30 18:49:30 +00:00
|
|
|
switch random.Uint32(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:35:11 +00:00
|
|
|
m.SetCopiesNumber(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))
|
|
|
|
m.SetHeader(GenerateHeader(empty))
|
|
|
|
|
|
|
|
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 {
|
2022-05-30 18:49:30 +00:00
|
|
|
switch random.Uint32(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 {
|
2022-05-30 18:49:30 +00:00
|
|
|
switch random.Uint32(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 {
|
2022-05-30 18:49:30 +00:00
|
|
|
switch random.Uint32(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
|
|
|
|
}
|