forked from TrueCloudLab/frostfs-api-go
acl: remove tests
This commit is contained in:
parent
ec4fb22e30
commit
0db55d31ae
3 changed files with 0 additions and 179 deletions
|
@ -1,76 +0,0 @@
|
|||
package acl
|
||||
|
||||
type testExtendedACLTable struct {
|
||||
records []ExtendedACLRecord
|
||||
}
|
||||
|
||||
type testRequestInfo struct {
|
||||
headers []TypedHeader
|
||||
key []byte
|
||||
opType OperationType
|
||||
target Target
|
||||
}
|
||||
|
||||
type testEACLRecord struct {
|
||||
opType OperationType
|
||||
filters []HeaderFilter
|
||||
targets []ExtendedACLTarget
|
||||
action ExtendedACLAction
|
||||
}
|
||||
|
||||
type testEACLTarget struct {
|
||||
target Target
|
||||
keys [][]byte
|
||||
}
|
||||
|
||||
func (s testEACLTarget) Target() Target {
|
||||
return s.target
|
||||
}
|
||||
|
||||
func (s testEACLTarget) KeyList() [][]byte {
|
||||
return s.keys
|
||||
}
|
||||
|
||||
func (s testEACLRecord) OperationType() OperationType {
|
||||
return s.opType
|
||||
}
|
||||
|
||||
func (s testEACLRecord) HeaderFilters() []HeaderFilter {
|
||||
return s.filters
|
||||
}
|
||||
|
||||
func (s testEACLRecord) TargetList() []ExtendedACLTarget {
|
||||
return s.targets
|
||||
}
|
||||
|
||||
func (s testEACLRecord) Action() ExtendedACLAction {
|
||||
return s.action
|
||||
}
|
||||
|
||||
func (s testRequestInfo) HeadersOfType(typ HeaderType) ([]Header, bool) {
|
||||
res := make([]Header, 0, len(s.headers))
|
||||
|
||||
for i := range s.headers {
|
||||
if s.headers[i].HeaderType() == typ {
|
||||
res = append(res, s.headers[i])
|
||||
}
|
||||
}
|
||||
|
||||
return res, true
|
||||
}
|
||||
|
||||
func (s testRequestInfo) Key() []byte {
|
||||
return s.key
|
||||
}
|
||||
|
||||
func (s testRequestInfo) TypeOf(t OperationType) bool {
|
||||
return s.opType == t
|
||||
}
|
||||
|
||||
func (s testRequestInfo) TargetOf(t Target) bool {
|
||||
return s.target == t
|
||||
}
|
||||
|
||||
func (s testExtendedACLTable) Records() []ExtendedACLRecord {
|
||||
return s.records
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
package acl
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/nspcc-dev/neofs-api-go/object"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestNewTypedObjectExtendedHeader(t *testing.T) {
|
||||
var res TypedHeader
|
||||
|
||||
hdr := object.Header{}
|
||||
|
||||
// nil value
|
||||
require.Nil(t, newTypedObjectExtendedHeader(hdr))
|
||||
|
||||
// UserHeader
|
||||
{
|
||||
key := "key"
|
||||
val := "val"
|
||||
hdr.Value = &object.Header_UserHeader{
|
||||
UserHeader: &object.UserHeader{
|
||||
Key: key,
|
||||
Value: val,
|
||||
},
|
||||
}
|
||||
|
||||
res = newTypedObjectExtendedHeader(hdr)
|
||||
require.Equal(t, HdrTypeObjUsr, res.HeaderType())
|
||||
require.Equal(t, key, res.Name())
|
||||
require.Equal(t, val, res.Value())
|
||||
}
|
||||
|
||||
{ // Link
|
||||
link := new(object.Link)
|
||||
link.ID = object.ID{1, 2, 3}
|
||||
|
||||
hdr.Value = &object.Header_Link{
|
||||
Link: link,
|
||||
}
|
||||
|
||||
check := func(lt object.Link_Type, name string) {
|
||||
link.Type = lt
|
||||
|
||||
res = newTypedObjectExtendedHeader(hdr)
|
||||
|
||||
require.Equal(t, HdrTypeObjSys, res.HeaderType())
|
||||
require.Equal(t, name, res.Name())
|
||||
require.Equal(t, link.ID.String(), res.Value())
|
||||
}
|
||||
|
||||
check(object.Link_Previous, HdrObjSysLinkPrev)
|
||||
check(object.Link_Next, HdrObjSysLinkNext)
|
||||
check(object.Link_Parent, HdrObjSysLinkPar)
|
||||
check(object.Link_Child, HdrObjSysLinkChild)
|
||||
check(object.Link_StorageGroup, HdrObjSysLinkSG)
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
package acl
|
||||
|
||||
type testTypedHeader struct {
|
||||
t HeaderType
|
||||
k string
|
||||
v string
|
||||
}
|
||||
|
||||
type testHeaderSrc struct {
|
||||
hs []TypedHeader
|
||||
}
|
||||
|
||||
type testHeaderFilter struct {
|
||||
TypedHeader
|
||||
t MatchType
|
||||
}
|
||||
|
||||
func (s testHeaderFilter) MatchType() MatchType {
|
||||
return s.t
|
||||
}
|
||||
|
||||
func (s testHeaderSrc) HeadersOfType(typ HeaderType) ([]Header, bool) {
|
||||
res := make([]Header, 0, len(s.hs))
|
||||
|
||||
for i := range s.hs {
|
||||
if s.hs[i].HeaderType() == typ {
|
||||
res = append(res, s.hs[i])
|
||||
}
|
||||
}
|
||||
|
||||
return res, true
|
||||
}
|
||||
|
||||
func (s testTypedHeader) Name() string {
|
||||
return s.k
|
||||
}
|
||||
|
||||
func (s testTypedHeader) Value() string {
|
||||
return s.v
|
||||
}
|
||||
|
||||
func (s testTypedHeader) HeaderType() HeaderType {
|
||||
return s.t
|
||||
}
|
Loading…
Reference in a new issue