forked from TrueCloudLab/frostfs-sdk-go
72 lines
1.1 KiB
Go
72 lines
1.1 KiB
Go
|
package test
|
||
|
|
||
|
import (
|
||
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/ape"
|
||
|
)
|
||
|
|
||
|
func GenerateRawChains(empty bool, n int) []*ape.Chain {
|
||
|
if empty {
|
||
|
return []*ape.Chain{}
|
||
|
}
|
||
|
|
||
|
res := make([]*ape.Chain, n)
|
||
|
for i := range res {
|
||
|
res[i] = GenerateRawChain(empty)
|
||
|
}
|
||
|
return res
|
||
|
}
|
||
|
|
||
|
func GenerateRawChain(empty bool) *ape.Chain {
|
||
|
chRaw := new(ape.ChainRaw)
|
||
|
|
||
|
if empty {
|
||
|
chRaw.SetRaw([]byte("{}"))
|
||
|
} else {
|
||
|
chRaw.SetRaw([]byte(`{
|
||
|
"ID": "",
|
||
|
"Rules": [
|
||
|
{
|
||
|
"Status": "Allow",
|
||
|
"Actions": {
|
||
|
"Inverted": false,
|
||
|
"Names": [
|
||
|
"GetObject"
|
||
|
]
|
||
|
},
|
||
|
"Resources": {
|
||
|
"Inverted": false,
|
||
|
"Names": [
|
||
|
"native:object/*"
|
||
|
]
|
||
|
},
|
||
|
"Any": false,
|
||
|
"Condition": [
|
||
|
{
|
||
|
"Op": "StringEquals",
|
||
|
"Object": "Resource",
|
||
|
"Key": "Department",
|
||
|
"Value": "HR"
|
||
|
}
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"MatchType": "DenyPriority"
|
||
|
}`))
|
||
|
}
|
||
|
|
||
|
ch := new(ape.Chain)
|
||
|
ch.SetKind(chRaw)
|
||
|
return ch
|
||
|
}
|
||
|
|
||
|
func GenerateChainTarget(empty bool) *ape.ChainTarget {
|
||
|
m := new(ape.ChainTarget)
|
||
|
|
||
|
if !empty {
|
||
|
m.SetTargetType(ape.TargetTypeContainer)
|
||
|
m.SetName("BzQw5HH3feoxFDD5tCT87Y1726qzgLfxEE7wgtoRzB3R")
|
||
|
}
|
||
|
|
||
|
return m
|
||
|
}
|