It allows filtering for specific rules and also the rules which are applied to the resource, and not to a specific resource. Introduces generic methods for RuleSet and FindRules method to access_control generation template.
51 lines
766 B
Go
51 lines
766 B
Go
package payload
|
|
|
|
import (
|
|
"github.com/cortezaproject/corteza-server/pkg/filter"
|
|
"github.com/stretchr/testify/require"
|
|
"testing"
|
|
)
|
|
|
|
func TestParseFilterState(t *testing.T) {
|
|
var (
|
|
req = require.New(t)
|
|
)
|
|
tests := []struct {
|
|
name string
|
|
input string
|
|
expected filter.State
|
|
}{
|
|
{
|
|
"invalid string should be Excluded",
|
|
"zero",
|
|
filter.StateExcluded,
|
|
},
|
|
{
|
|
"empty string should be Excluded",
|
|
"0",
|
|
filter.StateExcluded,
|
|
},
|
|
{
|
|
"Excluded",
|
|
"0",
|
|
filter.StateExcluded,
|
|
},
|
|
{
|
|
"Excluded",
|
|
"1",
|
|
filter.StateInclusive,
|
|
},
|
|
{
|
|
"Excluded",
|
|
"2",
|
|
filter.StateExclusive,
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
req.Equal(tt.expected, ParseFilterState(tt.input))
|
|
})
|
|
}
|
|
}
|