policy-engine/chain_test.go
Denis Kirillov 8d291039d8 [#11] Support inverted action and resource
Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
2023-11-02 12:24:37 +03:00

33 lines
569 B
Go

package policyengine
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestEncodeDecode(t *testing.T) {
expected := Chain{
Rules: []Rule{
{
Status: Allow,
Actions: Actions{Names: []string{
"native::PutObject",
}},
Resources: Resources{Names: []string{"*"}},
Condition: []Condition{
{
Op: CondStringEquals,
Key: "Name",
Value: "NNS",
},
},
},
},
}
data := expected.Bytes()
var actual Chain
require.NoError(t, actual.DecodeBytes(data))
require.Equal(t, expected, actual)
}