33 lines
786 B
Go
33 lines
786 B
Go
|
|
package policytest
|
||
|
|
|
||
|
|
import (
|
||
|
|
"testing"
|
||
|
|
|
||
|
|
"github.com/stretchr/testify/assert"
|
||
|
|
)
|
||
|
|
|
||
|
|
// TestInvocationValidation applies the example policy to the second
|
||
|
|
// example arguments as defined in the [Validation] section of the
|
||
|
|
// invocation specification.
|
||
|
|
//
|
||
|
|
// [Validation]: https://github.com/ucan-wg/delegation/tree/v1_ipld#validation
|
||
|
|
func TestInvocationValidationSpecExamples(t *testing.T) {
|
||
|
|
t.Parallel()
|
||
|
|
|
||
|
|
t.Run("with passing args", func(t *testing.T) {
|
||
|
|
t.Parallel()
|
||
|
|
|
||
|
|
exec, stmt := ExamplePolicy.Match(exampleValidArgumentsIPLD)
|
||
|
|
assert.True(t, exec)
|
||
|
|
assert.Nil(t, stmt)
|
||
|
|
})
|
||
|
|
|
||
|
|
t.Run("fails on recipients (second statement)", func(t *testing.T) {
|
||
|
|
t.Parallel()
|
||
|
|
|
||
|
|
exec, stmt := ExamplePolicy.Match(exampleInvalidArgumentsIPLD)
|
||
|
|
assert.False(t, exec)
|
||
|
|
assert.NotNil(t, stmt)
|
||
|
|
})
|
||
|
|
}
|