All checks were successful
* 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
131 lines
2.3 KiB
Go
131 lines
2.3 KiB
Go
package acltest
|
|
|
|
import (
|
|
acl "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/acl/grpc"
|
|
accountingtest "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs/test"
|
|
)
|
|
|
|
func GenerateBearerToken(empty bool) *acl.BearerToken {
|
|
m := new(acl.BearerToken)
|
|
|
|
if !empty {
|
|
m.SetBody(GenerateBearerTokenBody(false))
|
|
}
|
|
|
|
m.SetSignature(accountingtest.GenerateSignature(empty))
|
|
|
|
return m
|
|
}
|
|
|
|
func GenerateBearerTokenBody(empty bool) *acl.BearerToken_Body {
|
|
m := new(acl.BearerToken_Body)
|
|
|
|
if !empty {
|
|
m.SetOwnerId(accountingtest.GenerateOwnerID(false))
|
|
m.SetEaclTable(GenerateTable(false))
|
|
m.SetLifetime(GenerateTokenLifetime(false))
|
|
}
|
|
|
|
return m
|
|
}
|
|
|
|
func GenerateTable(empty bool) *acl.EACLTable {
|
|
m := new(acl.EACLTable)
|
|
|
|
if !empty {
|
|
m.SetRecords(GenerateRecords(false))
|
|
m.SetContainerId(accountingtest.GenerateContainerID(false))
|
|
}
|
|
|
|
m.SetVersion(accountingtest.GenerateVersion(empty))
|
|
|
|
return m
|
|
}
|
|
|
|
func GenerateRecords(empty bool) []*acl.EACLRecord {
|
|
var rs []*acl.EACLRecord
|
|
|
|
if !empty {
|
|
rs = append(rs,
|
|
GenerateRecord(false),
|
|
GenerateRecord(false),
|
|
)
|
|
}
|
|
|
|
return rs
|
|
}
|
|
|
|
func GenerateRecord(empty bool) *acl.EACLRecord {
|
|
m := new(acl.EACLRecord)
|
|
|
|
if !empty {
|
|
m.SetAction(acl.Action_ALLOW)
|
|
m.SetOperation(acl.Operation_GET)
|
|
m.SetFilters(GenerateFilters(false))
|
|
m.SetTargets(GenerateTargets(false))
|
|
}
|
|
|
|
return m
|
|
}
|
|
|
|
func GenerateFilters(empty bool) []*acl.EACLRecord_Filter {
|
|
var fs []*acl.EACLRecord_Filter
|
|
|
|
if !empty {
|
|
fs = append(fs,
|
|
GenerateFilter(false),
|
|
GenerateFilter(false),
|
|
)
|
|
}
|
|
|
|
return fs
|
|
}
|
|
|
|
func GenerateFilter(empty bool) *acl.EACLRecord_Filter {
|
|
m := new(acl.EACLRecord_Filter)
|
|
|
|
if !empty {
|
|
m.SetKey("key")
|
|
m.SetValue("val")
|
|
m.SetHeader(acl.HeaderType_REQUEST)
|
|
m.SetMatchType(acl.MatchType_STRING_EQUAL)
|
|
}
|
|
|
|
return m
|
|
}
|
|
|
|
func GenerateTargets(empty bool) []*acl.EACLRecord_Target {
|
|
var ts []*acl.EACLRecord_Target
|
|
|
|
if !empty {
|
|
ts = append(ts,
|
|
GenerateTarget(false),
|
|
GenerateTarget(false),
|
|
)
|
|
}
|
|
|
|
return ts
|
|
}
|
|
|
|
func GenerateTarget(empty bool) *acl.EACLRecord_Target {
|
|
m := new(acl.EACLRecord_Target)
|
|
|
|
if !empty {
|
|
m.SetRole(acl.Role_SYSTEM)
|
|
m.SetKeys([][]byte{{1}, {2}})
|
|
}
|
|
|
|
return m
|
|
}
|
|
|
|
func GenerateTokenLifetime(empty bool) *acl.BearerToken_Body_TokenLifetime {
|
|
m := new(acl.BearerToken_Body_TokenLifetime)
|
|
|
|
if !empty {
|
|
m.SetExp(1)
|
|
m.SetIat(2)
|
|
m.SetExp(3)
|
|
}
|
|
|
|
return m
|
|
}
|