2023-10-17 14:10:48 +00:00
|
|
|
package policyengine
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestEncodeDecode(t *testing.T) {
|
|
|
|
expected := Chain{
|
|
|
|
Rules: []Rule{
|
|
|
|
{
|
|
|
|
Status: Allow,
|
2023-10-30 13:34:11 +00:00
|
|
|
Actions: Actions{Names: []string{
|
2023-10-17 14:10:48 +00:00
|
|
|
"native::PutObject",
|
2023-10-30 13:34:11 +00:00
|
|
|
}},
|
|
|
|
Resources: Resources{Names: []string{"*"}},
|
2023-10-17 14:10:48 +00:00
|
|
|
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)
|
|
|
|
}
|