forked from TrueCloudLab/frostfs-api-go
* Add plugin option for protogen in Makefile * Fix the generator for the plugin in util/protogen * Erase convertable types, move helpful methods to gRPC protobufs * Erase helpers for convertations * Generate StableMarshlal/StableSize for protobufs by the protoc plugin Signed-off-by: Airat Arifullin a.arifullin@yadro.com
396 lines
9.3 KiB
Go
396 lines
9.3 KiB
Go
package containertest
|
|
|
|
import (
|
|
acltest "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/acl/test"
|
|
container "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/container/grpc"
|
|
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"
|
|
)
|
|
|
|
func GenerateAttribute(empty bool) *container.Container_Attribute {
|
|
m := new(container.Container_Attribute)
|
|
|
|
if !empty {
|
|
m.SetKey("key")
|
|
m.SetValue("val")
|
|
}
|
|
|
|
return m
|
|
}
|
|
|
|
func GenerateAttributes(empty bool) []*container.Container_Attribute {
|
|
var res []*container.Container_Attribute
|
|
|
|
if !empty {
|
|
res = append(res,
|
|
GenerateAttribute(false),
|
|
GenerateAttribute(false),
|
|
)
|
|
}
|
|
|
|
return res
|
|
}
|
|
|
|
func GenerateContainer(empty bool) *container.Container {
|
|
m := new(container.Container)
|
|
|
|
if !empty {
|
|
m.SetBasicAcl(12)
|
|
m.SetNonce([]byte{1, 2, 3})
|
|
m.SetOwnerId(refstest.GenerateOwnerID(false))
|
|
m.SetAttributes(GenerateAttributes(false))
|
|
m.SetPlacementPolicy(netmaptest.GeneratePlacementPolicy(false))
|
|
}
|
|
|
|
m.SetVersion(refstest.GenerateVersion(empty))
|
|
|
|
return m
|
|
}
|
|
|
|
func GeneratePutRequestBody(empty bool) *container.PutRequest_Body {
|
|
m := new(container.PutRequest_Body)
|
|
|
|
if !empty {
|
|
m.SetContainer(GenerateContainer(false))
|
|
}
|
|
|
|
m.SetSignature(refstest.GenerateSignatureRFC6979(empty))
|
|
|
|
return m
|
|
}
|
|
|
|
func GeneratePutRequest(empty bool) *container.PutRequest {
|
|
m := new(container.PutRequest)
|
|
|
|
if !empty {
|
|
m.SetBody(GeneratePutRequestBody(false))
|
|
}
|
|
|
|
m.SetMetaHeader(sessiontest.GenerateRequestMetaHeader(empty))
|
|
m.SetVerifyHeader(sessiontest.GenerateRequestVerificationHeader(empty))
|
|
|
|
return m
|
|
}
|
|
|
|
func GeneratePutResponseBody(empty bool) *container.PutResponse_Body {
|
|
m := new(container.PutResponse_Body)
|
|
|
|
if !empty {
|
|
m.SetContainerId(refstest.GenerateContainerID(false))
|
|
}
|
|
|
|
return m
|
|
}
|
|
|
|
func GeneratePutResponse(empty bool) *container.PutResponse {
|
|
m := new(container.PutResponse)
|
|
|
|
if !empty {
|
|
m.SetBody(GeneratePutResponseBody(false))
|
|
}
|
|
|
|
m.SetMetaHeader(sessiontest.GenerateResponseMetaHeader(empty))
|
|
m.SetVerifyHeader(sessiontest.GenerateResponseVerificationHeader(empty))
|
|
|
|
return m
|
|
}
|
|
|
|
func GenerateGetRequestBody(empty bool) *container.GetRequest_Body {
|
|
m := new(container.GetRequest_Body)
|
|
|
|
if !empty {
|
|
m.SetContainerId(refstest.GenerateContainerID(false))
|
|
}
|
|
|
|
return m
|
|
}
|
|
|
|
func GenerateGetRequest(empty bool) *container.GetRequest {
|
|
m := new(container.GetRequest)
|
|
|
|
if !empty {
|
|
m.SetBody(GenerateGetRequestBody(false))
|
|
}
|
|
|
|
m.SetMetaHeader(sessiontest.GenerateRequestMetaHeader(empty))
|
|
m.SetVerifyHeader(sessiontest.GenerateRequestVerificationHeader(empty))
|
|
|
|
return m
|
|
}
|
|
|
|
func GenerateGetResponseBody(empty bool) *container.GetResponse_Body {
|
|
m := new(container.GetResponse_Body)
|
|
|
|
if !empty {
|
|
m.SetContainer(GenerateContainer(false))
|
|
}
|
|
|
|
m.SetSignature(refstest.GenerateSignatureRFC6979(empty))
|
|
m.SetSessionToken(sessiontest.GenerateSessionToken(empty))
|
|
|
|
return m
|
|
}
|
|
|
|
func GenerateGetResponse(empty bool) *container.GetResponse {
|
|
m := new(container.GetResponse)
|
|
|
|
if !empty {
|
|
m.SetBody(GenerateGetResponseBody(false))
|
|
}
|
|
|
|
m.SetMetaHeader(sessiontest.GenerateResponseMetaHeader(empty))
|
|
m.SetVerifyHeader(sessiontest.GenerateResponseVerificationHeader(empty))
|
|
|
|
return m
|
|
}
|
|
|
|
func GenerateDeleteRequestBody(empty bool) *container.DeleteRequest_Body {
|
|
m := new(container.DeleteRequest_Body)
|
|
|
|
if !empty {
|
|
m.SetContainerId(refstest.GenerateContainerID(false))
|
|
}
|
|
|
|
m.SetSignature(refstest.GenerateSignatureRFC6979(empty))
|
|
|
|
return m
|
|
}
|
|
|
|
func GenerateDeleteRequest(empty bool) *container.DeleteRequest {
|
|
m := new(container.DeleteRequest)
|
|
|
|
if !empty {
|
|
m.SetBody(GenerateDeleteRequestBody(false))
|
|
}
|
|
|
|
m.SetMetaHeader(sessiontest.GenerateRequestMetaHeader(empty))
|
|
m.SetVerifyHeader(sessiontest.GenerateRequestVerificationHeader(empty))
|
|
|
|
return m
|
|
}
|
|
|
|
func GenerateDeleteResponseBody(_ bool) *container.DeleteResponse_Body {
|
|
m := new(container.DeleteResponse_Body)
|
|
|
|
return m
|
|
}
|
|
|
|
func GenerateDeleteResponse(empty bool) *container.DeleteResponse {
|
|
m := new(container.DeleteResponse)
|
|
|
|
if !empty {
|
|
m.SetBody(GenerateDeleteResponseBody(false))
|
|
}
|
|
|
|
m.SetMetaHeader(sessiontest.GenerateResponseMetaHeader(empty))
|
|
m.SetVerifyHeader(sessiontest.GenerateResponseVerificationHeader(empty))
|
|
|
|
return m
|
|
}
|
|
|
|
func GenerateListRequestBody(empty bool) *container.ListRequest_Body {
|
|
m := new(container.ListRequest_Body)
|
|
|
|
if !empty {
|
|
m.SetOwnerId(refstest.GenerateOwnerID(false))
|
|
}
|
|
|
|
return m
|
|
}
|
|
|
|
func GenerateListRequest(empty bool) *container.ListRequest {
|
|
m := new(container.ListRequest)
|
|
|
|
if !empty {
|
|
m.SetBody(GenerateListRequestBody(false))
|
|
}
|
|
|
|
m.SetMetaHeader(sessiontest.GenerateRequestMetaHeader(empty))
|
|
m.SetVerifyHeader(sessiontest.GenerateRequestVerificationHeader(empty))
|
|
|
|
return m
|
|
}
|
|
|
|
func GenerateListResponseBody(empty bool) *container.ListResponse_Body {
|
|
m := new(container.ListResponse_Body)
|
|
|
|
if !empty {
|
|
m.SetContainerIds(refstest.GenerateContainerIDs(false))
|
|
}
|
|
|
|
return m
|
|
}
|
|
|
|
func GenerateListResponse(empty bool) *container.ListResponse {
|
|
m := new(container.ListResponse)
|
|
|
|
if !empty {
|
|
m.SetBody(GenerateListResponseBody(false))
|
|
}
|
|
|
|
m.SetMetaHeader(sessiontest.GenerateResponseMetaHeader(empty))
|
|
m.SetVerifyHeader(sessiontest.GenerateResponseVerificationHeader(empty))
|
|
|
|
return m
|
|
}
|
|
|
|
func GenerateSetExtendedACLRequestBody(empty bool) *container.SetExtendedACLRequest_Body {
|
|
m := new(container.SetExtendedACLRequest_Body)
|
|
|
|
if !empty {
|
|
m.SetEacl(acltest.GenerateTable(false))
|
|
}
|
|
|
|
m.SetSignature(refstest.GenerateSignatureRFC6979(empty))
|
|
|
|
return m
|
|
}
|
|
|
|
func GenerateSetExtendedACLRequest(empty bool) *container.SetExtendedACLRequest {
|
|
m := new(container.SetExtendedACLRequest)
|
|
|
|
if !empty {
|
|
m.SetBody(GenerateSetExtendedACLRequestBody(false))
|
|
}
|
|
|
|
m.SetMetaHeader(sessiontest.GenerateRequestMetaHeader(empty))
|
|
m.SetVerifyHeader(sessiontest.GenerateRequestVerificationHeader(empty))
|
|
|
|
return m
|
|
}
|
|
|
|
func GenerateSetExtendedACLResponseBody(_ bool) *container.SetExtendedACLResponse_Body {
|
|
m := new(container.SetExtendedACLResponse_Body)
|
|
|
|
return m
|
|
}
|
|
|
|
func GenerateSetExtendedACLResponse(empty bool) *container.SetExtendedACLResponse {
|
|
m := new(container.SetExtendedACLResponse)
|
|
|
|
if !empty {
|
|
m.SetBody(GenerateSetExtendedACLResponseBody(false))
|
|
}
|
|
|
|
m.SetMetaHeader(sessiontest.GenerateResponseMetaHeader(empty))
|
|
m.SetVerifyHeader(sessiontest.GenerateResponseVerificationHeader(empty))
|
|
|
|
return m
|
|
}
|
|
|
|
func GenerateGetExtendedACLRequestBody(empty bool) *container.GetExtendedACLRequest_Body {
|
|
m := new(container.GetExtendedACLRequest_Body)
|
|
|
|
if !empty {
|
|
m.SetContainerId(refstest.GenerateContainerID(false))
|
|
}
|
|
|
|
return m
|
|
}
|
|
|
|
func GenerateGetExtendedACLRequest(empty bool) *container.GetExtendedACLRequest {
|
|
m := new(container.GetExtendedACLRequest)
|
|
|
|
if !empty {
|
|
m.SetBody(GenerateGetExtendedACLRequestBody(false))
|
|
}
|
|
|
|
m.SetMetaHeader(sessiontest.GenerateRequestMetaHeader(empty))
|
|
m.SetVerifyHeader(sessiontest.GenerateRequestVerificationHeader(empty))
|
|
|
|
return m
|
|
}
|
|
|
|
func GenerateGetExtendedACLResponseBody(empty bool) *container.GetExtendedACLResponse_Body {
|
|
m := new(container.GetExtendedACLResponse_Body)
|
|
|
|
if !empty {
|
|
m.SetEacl(acltest.GenerateTable(false))
|
|
}
|
|
|
|
m.SetSignature(refstest.GenerateSignatureRFC6979(empty))
|
|
m.SetSessionToken(sessiontest.GenerateSessionToken(empty))
|
|
|
|
return m
|
|
}
|
|
|
|
func GenerateGetExtendedACLResponse(empty bool) *container.GetExtendedACLResponse {
|
|
m := new(container.GetExtendedACLResponse)
|
|
|
|
if !empty {
|
|
m.SetBody(GenerateGetExtendedACLResponseBody(false))
|
|
}
|
|
|
|
m.SetMetaHeader(sessiontest.GenerateResponseMetaHeader(empty))
|
|
m.SetVerifyHeader(sessiontest.GenerateResponseVerificationHeader(empty))
|
|
|
|
return m
|
|
}
|
|
|
|
func GenerateUsedSpaceAnnouncement(empty bool) *container.AnnounceUsedSpaceRequest_Body_Announcement {
|
|
m := new(container.AnnounceUsedSpaceRequest_Body_Announcement)
|
|
|
|
if !empty {
|
|
m.SetContainerId(refstest.GenerateContainerID(false))
|
|
m.SetEpoch(1)
|
|
m.SetUsedSpace(2)
|
|
}
|
|
|
|
return m
|
|
}
|
|
|
|
func GenerateUsedSpaceAnnouncements(empty bool) []*container.AnnounceUsedSpaceRequest_Body_Announcement {
|
|
var res []*container.AnnounceUsedSpaceRequest_Body_Announcement
|
|
|
|
if !empty {
|
|
res = append(res,
|
|
GenerateUsedSpaceAnnouncement(false),
|
|
GenerateUsedSpaceAnnouncement(false),
|
|
)
|
|
}
|
|
|
|
return res
|
|
}
|
|
|
|
func GenerateAnnounceUsedSpaceRequestBody(empty bool) *container.AnnounceUsedSpaceRequest_Body {
|
|
m := new(container.AnnounceUsedSpaceRequest_Body)
|
|
|
|
if !empty {
|
|
m.SetAnnouncements(GenerateUsedSpaceAnnouncements(false))
|
|
}
|
|
|
|
return m
|
|
}
|
|
|
|
func GenerateAnnounceUsedSpaceRequest(empty bool) *container.AnnounceUsedSpaceRequest {
|
|
m := new(container.AnnounceUsedSpaceRequest)
|
|
|
|
if !empty {
|
|
m.SetBody(GenerateAnnounceUsedSpaceRequestBody(false))
|
|
}
|
|
|
|
m.SetMetaHeader(sessiontest.GenerateRequestMetaHeader(empty))
|
|
m.SetVerifyHeader(sessiontest.GenerateRequestVerificationHeader(empty))
|
|
|
|
return m
|
|
}
|
|
|
|
func GenerateAnnounceUsedSpaceResponseBody(_ bool) *container.AnnounceUsedSpaceResponse_Body {
|
|
m := new(container.AnnounceUsedSpaceResponse_Body)
|
|
|
|
return m
|
|
}
|
|
|
|
func GenerateAnnounceUsedSpaceResponse(empty bool) *container.AnnounceUsedSpaceResponse {
|
|
m := new(container.AnnounceUsedSpaceResponse)
|
|
|
|
if !empty {
|
|
m.SetBody(GenerateAnnounceUsedSpaceResponseBody(false))
|
|
}
|
|
|
|
m.SetMetaHeader(sessiontest.GenerateResponseMetaHeader(empty))
|
|
m.SetVerifyHeader(sessiontest.GenerateResponseVerificationHeader(empty))
|
|
|
|
return m
|
|
}
|