2021-03-12 12:57:23 +00:00
|
|
|
package containertest
|
|
|
|
|
|
|
|
import (
|
2023-03-07 10:38:56 +00:00
|
|
|
acltest "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/acl/test"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/container"
|
|
|
|
netmaptest "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/netmap/test"
|
|
|
|
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 GenerateAttribute(empty bool) *container.Attribute {
|
|
|
|
m := new(container.Attribute)
|
|
|
|
|
|
|
|
if !empty {
|
|
|
|
m.SetKey("key")
|
|
|
|
m.SetValue("val")
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2022-03-02 08:18:59 +00:00
|
|
|
func GenerateAttributes(empty bool) []container.Attribute {
|
|
|
|
var res []container.Attribute
|
2021-06-11 12:17:09 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if !empty {
|
|
|
|
res = append(res,
|
2022-03-02 08:18:59 +00:00
|
|
|
*GenerateAttribute(false),
|
|
|
|
*GenerateAttribute(false),
|
2021-03-12 12:57:23 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-06-11 12:17:09 +00:00
|
|
|
return res
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateContainer(empty bool) *container.Container {
|
|
|
|
m := new(container.Container)
|
|
|
|
|
|
|
|
if !empty {
|
|
|
|
m.SetBasicACL(12)
|
|
|
|
m.SetNonce([]byte{1, 2, 3})
|
2021-06-11 12:17:09 +00:00
|
|
|
m.SetOwnerID(refstest.GenerateOwnerID(false))
|
|
|
|
m.SetAttributes(GenerateAttributes(false))
|
|
|
|
m.SetPlacementPolicy(netmaptest.GeneratePlacementPolicy(false))
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m.SetVersion(refstest.GenerateVersion(empty))
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GeneratePutRequestBody(empty bool) *container.PutRequestBody {
|
|
|
|
m := new(container.PutRequestBody)
|
|
|
|
|
2021-06-11 12:17:09 +00:00
|
|
|
if !empty {
|
|
|
|
m.SetContainer(GenerateContainer(false))
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetSignature(refstest.GenerateSignature(empty))
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GeneratePutRequest(empty bool) *container.PutRequest {
|
|
|
|
m := new(container.PutRequest)
|
|
|
|
|
2021-06-11 12:17:09 +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) *container.PutResponseBody {
|
|
|
|
m := new(container.PutResponseBody)
|
|
|
|
|
2021-06-11 12:17:09 +00:00
|
|
|
if !empty {
|
|
|
|
m.SetContainerID(refstest.GenerateContainerID(false))
|
|
|
|
}
|
2021-03-12 12:57:23 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GeneratePutResponse(empty bool) *container.PutResponse {
|
|
|
|
m := new(container.PutResponse)
|
|
|
|
|
2021-06-11 12:17:09 +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 GenerateGetRequestBody(empty bool) *container.GetRequestBody {
|
|
|
|
m := new(container.GetRequestBody)
|
|
|
|
|
2021-06-11 12:17:09 +00:00
|
|
|
if !empty {
|
|
|
|
m.SetContainerID(refstest.GenerateContainerID(false))
|
|
|
|
}
|
2021-03-12 12:57:23 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateGetRequest(empty bool) *container.GetRequest {
|
|
|
|
m := new(container.GetRequest)
|
|
|
|
|
2021-06-11 12:17:09 +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 GenerateGetResponseBody(empty bool) *container.GetResponseBody {
|
|
|
|
m := new(container.GetResponseBody)
|
|
|
|
|
2021-06-11 12:17:09 +00:00
|
|
|
if !empty {
|
|
|
|
m.SetContainer(GenerateContainer(false))
|
|
|
|
}
|
|
|
|
|
2021-05-24 18:20:23 +00:00
|
|
|
m.SetSignature(refstest.GenerateSignature(empty))
|
|
|
|
m.SetSessionToken(sessiontest.GenerateSessionToken(empty))
|
2021-03-12 12:57:23 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateGetResponse(empty bool) *container.GetResponse {
|
|
|
|
m := new(container.GetResponse)
|
|
|
|
|
2021-06-11 12:17:09 +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 GenerateDeleteRequestBody(empty bool) *container.DeleteRequestBody {
|
|
|
|
m := new(container.DeleteRequestBody)
|
|
|
|
|
2021-06-11 12:17:09 +00:00
|
|
|
if !empty {
|
|
|
|
m.SetContainerID(refstest.GenerateContainerID(false))
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetSignature(refstest.GenerateSignature(empty))
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateDeleteRequest(empty bool) *container.DeleteRequest {
|
|
|
|
m := new(container.DeleteRequest)
|
|
|
|
|
2021-06-11 12:17:09 +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
|
|
|
|
}
|
|
|
|
|
2023-05-03 10:41:27 +00:00
|
|
|
func GenerateDeleteResponseBody(_ bool) *container.DeleteResponseBody {
|
2021-03-12 12:57:23 +00:00
|
|
|
m := new(container.DeleteResponseBody)
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateDeleteResponse(empty bool) *container.DeleteResponse {
|
|
|
|
m := new(container.DeleteResponse)
|
|
|
|
|
2021-06-11 12:17:09 +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 GenerateListRequestBody(empty bool) *container.ListRequestBody {
|
|
|
|
m := new(container.ListRequestBody)
|
|
|
|
|
2021-06-11 12:17:09 +00:00
|
|
|
if !empty {
|
|
|
|
m.SetOwnerID(refstest.GenerateOwnerID(false))
|
|
|
|
}
|
2021-03-12 12:57:23 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateListRequest(empty bool) *container.ListRequest {
|
|
|
|
m := new(container.ListRequest)
|
|
|
|
|
2021-06-11 12:17:09 +00:00
|
|
|
if !empty {
|
|
|
|
m.SetBody(GenerateListRequestBody(false))
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetMetaHeader(sessiontest.GenerateRequestMetaHeader(empty))
|
|
|
|
m.SetVerificationHeader(sessiontest.GenerateRequestVerificationHeader(empty))
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateListResponseBody(empty bool) *container.ListResponseBody {
|
|
|
|
m := new(container.ListResponseBody)
|
|
|
|
|
2021-06-11 12:17:09 +00:00
|
|
|
if !empty {
|
|
|
|
m.SetContainerIDs(refstest.GenerateContainerIDs(false))
|
|
|
|
}
|
2021-03-12 12:57:23 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateListResponse(empty bool) *container.ListResponse {
|
|
|
|
m := new(container.ListResponse)
|
|
|
|
|
2021-06-11 12:17:09 +00:00
|
|
|
if !empty {
|
|
|
|
m.SetBody(GenerateListResponseBody(false))
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetMetaHeader(sessiontest.GenerateResponseMetaHeader(empty))
|
|
|
|
m.SetVerificationHeader(sessiontest.GenerateResponseVerificationHeader(empty))
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateGetExtendedACLRequestBody(empty bool) *container.GetExtendedACLRequestBody {
|
|
|
|
m := new(container.GetExtendedACLRequestBody)
|
|
|
|
|
2021-06-11 12:17:09 +00:00
|
|
|
if !empty {
|
|
|
|
m.SetContainerID(refstest.GenerateContainerID(false))
|
|
|
|
}
|
2021-03-12 12:57:23 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateGetExtendedACLRequest(empty bool) *container.GetExtendedACLRequest {
|
|
|
|
m := new(container.GetExtendedACLRequest)
|
|
|
|
|
2021-06-11 12:17:09 +00:00
|
|
|
if !empty {
|
|
|
|
m.SetBody(GenerateGetExtendedACLRequestBody(false))
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetMetaHeader(sessiontest.GenerateRequestMetaHeader(empty))
|
|
|
|
m.SetVerificationHeader(sessiontest.GenerateRequestVerificationHeader(empty))
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateGetExtendedACLResponseBody(empty bool) *container.GetExtendedACLResponseBody {
|
|
|
|
m := new(container.GetExtendedACLResponseBody)
|
|
|
|
|
2021-06-11 12:17:09 +00:00
|
|
|
if !empty {
|
|
|
|
m.SetEACL(acltest.GenerateTable(false))
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetSignature(refstest.GenerateSignature(empty))
|
2021-05-24 18:20:23 +00:00
|
|
|
m.SetSessionToken(sessiontest.GenerateSessionToken(empty))
|
2021-03-12 12:57:23 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateGetExtendedACLResponse(empty bool) *container.GetExtendedACLResponse {
|
|
|
|
m := new(container.GetExtendedACLResponse)
|
|
|
|
|
2021-06-11 12:17:09 +00:00
|
|
|
if !empty {
|
|
|
|
m.SetBody(GenerateGetExtendedACLResponseBody(false))
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetMetaHeader(sessiontest.GenerateResponseMetaHeader(empty))
|
|
|
|
m.SetVerificationHeader(sessiontest.GenerateResponseVerificationHeader(empty))
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|