forked from TrueCloudLab/policy-engine
34 lines
533 B
Go
34 lines
533 B
Go
|
package policyengine
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"github.com/stretchr/testify/require"
|
||
|
)
|
||
|
|
||
|
func TestEncodeDecode(t *testing.T) {
|
||
|
expected := Chain{
|
||
|
Rules: []Rule{
|
||
|
{
|
||
|
Status: Allow,
|
||
|
Action: []string{
|
||
|
"native::PutObject",
|
||
|
},
|
||
|
Resource: []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)
|
||
|
}
|