From 0db55d31ae0a24a7a603d827522d6960381b582f Mon Sep 17 00:00:00 2001 From: Pavel Korotkov Date: Tue, 7 Jul 2020 19:43:16 +0300 Subject: [PATCH] acl: remove tests --- acl/action_test.go | 76 --------------------------------------------- acl/headers_test.go | 59 ----------------------------------- acl/match_test.go | 44 -------------------------- 3 files changed, 179 deletions(-) delete mode 100644 acl/action_test.go delete mode 100644 acl/headers_test.go delete mode 100644 acl/match_test.go diff --git a/acl/action_test.go b/acl/action_test.go deleted file mode 100644 index 83022e3..0000000 --- a/acl/action_test.go +++ /dev/null @@ -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 -} diff --git a/acl/headers_test.go b/acl/headers_test.go deleted file mode 100644 index 500d9a4..0000000 --- a/acl/headers_test.go +++ /dev/null @@ -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) - } -} diff --git a/acl/match_test.go b/acl/match_test.go deleted file mode 100644 index 6975722..0000000 --- a/acl/match_test.go +++ /dev/null @@ -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 -}