[#139] sdk/acl: Add test coverage for EACL structures
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
790add6538
commit
d1499e65b9
5 changed files with 334 additions and 2 deletions
38
pkg/acl/eacl/target_test.go
Normal file
38
pkg/acl/eacl/target_test.go
Normal file
|
@ -0,0 +1,38 @@
|
|||
package eacl
|
||||
|
||||
import (
|
||||
"crypto/ecdsa"
|
||||
"testing"
|
||||
|
||||
v2acl "github.com/nspcc-dev/neofs-api-go/v2/acl"
|
||||
crypto "github.com/nspcc-dev/neofs-crypto"
|
||||
"github.com/nspcc-dev/neofs-crypto/test"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestTarget(t *testing.T) {
|
||||
keys := []ecdsa.PublicKey{
|
||||
test.DecodeKey(1).PublicKey,
|
||||
test.DecodeKey(2).PublicKey,
|
||||
}
|
||||
|
||||
target := &Target{
|
||||
role: RoleSystem,
|
||||
keys: keys,
|
||||
}
|
||||
|
||||
v2 := target.ToV2()
|
||||
require.NotNil(t, v2)
|
||||
require.Equal(t, v2acl.RoleSystem, v2.GetRole())
|
||||
require.Len(t, v2.GetKeyList(), len(keys))
|
||||
for i, key := range v2.GetKeyList() {
|
||||
require.Equal(t, key, crypto.MarshalPublicKey(&keys[i]))
|
||||
}
|
||||
|
||||
newTarget := NewTargetFromV2(v2)
|
||||
require.Equal(t, target, newTarget)
|
||||
|
||||
t.Run("from nil v2 target", func(t *testing.T) {
|
||||
require.Equal(t, new(Target), NewTargetFromV2(nil))
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue