policy: fix tests now that selector evaluation is clearer
https://github.com/ucan-wg/delegation/pull/15 https://github.com/ucan-wg/delegation/pull/16
This commit is contained in:
@@ -57,7 +57,7 @@ Not implemented yet:
|
|||||||
|
|
||||||
Besides that, `go-ucan` also includes:
|
Besides that, `go-ucan` also includes:
|
||||||
- a simplified [DID](https://www.w3.org/TR/did-core/) and [did-key](https://w3c-ccg.github.io/did-method-key/) implementation
|
- a simplified [DID](https://www.w3.org/TR/did-core/) and [did-key](https://w3c-ccg.github.io/did-method-key/) implementation
|
||||||
- a [token container](https://github.com/ucan-wg/go-ucan/tree/v1/pkg/container) with CBOR and CAR format, to package and carry tokens together
|
- a [token container](https://github.com/ucan-wg/go-ucan/tree/v1/pkg/container) with CBOR and CAR format, to package and carry tokens together, see [SPEC](pkg/container/SPEC.md)
|
||||||
- support for encrypted values in token's metadata
|
- support for encrypted values in token's metadata
|
||||||
|
|
||||||
## Getting Help
|
## Getting Help
|
||||||
|
|||||||
@@ -135,8 +135,6 @@ func TestMatch(t *testing.T) {
|
|||||||
require.Equal(t, pol[0], leaf)
|
require.Equal(t, pol[0], leaf)
|
||||||
})
|
})
|
||||||
|
|
||||||
// ------------
|
|
||||||
|
|
||||||
t.Run("neq string", func(t *testing.T) {
|
t.Run("neq string", func(t *testing.T) {
|
||||||
nd := literal.String("test")
|
nd := literal.String("test")
|
||||||
|
|
||||||
@@ -236,11 +234,11 @@ func TestMatch(t *testing.T) {
|
|||||||
require.True(t, ok)
|
require.True(t, ok)
|
||||||
require.Nil(t, leaf)
|
require.Nil(t, leaf)
|
||||||
|
|
||||||
// TODO: clarify how it behave when the data is missing
|
// missing data will fail, as not optional
|
||||||
pol = MustConstruct(NotEqual(".foobar", literal.String("bar")))
|
pol = MustConstruct(NotEqual(".foobar", literal.String("bar")))
|
||||||
ok, leaf = pol.Match(nd)
|
ok, leaf = pol.Match(nd)
|
||||||
require.True(t, ok)
|
require.False(t, ok)
|
||||||
require.Nil(t, leaf)
|
require.Equal(t, pol[0], leaf)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("neq string in list", func(t *testing.T) {
|
t.Run("neq string in list", func(t *testing.T) {
|
||||||
@@ -251,11 +249,16 @@ func TestMatch(t *testing.T) {
|
|||||||
require.False(t, ok)
|
require.False(t, ok)
|
||||||
require.Equal(t, pol[0], leaf)
|
require.Equal(t, pol[0], leaf)
|
||||||
|
|
||||||
// TODO: clarify how it behave when the data is missing
|
pol = MustConstruct(NotEqual(".[0]", literal.String("bar")))
|
||||||
pol = MustConstruct(NotEqual(".[1]", literal.String("foo")))
|
|
||||||
ok, leaf = pol.Match(nd)
|
ok, leaf = pol.Match(nd)
|
||||||
require.True(t, ok)
|
require.True(t, ok)
|
||||||
require.Nil(t, leaf)
|
require.Nil(t, leaf)
|
||||||
|
|
||||||
|
// missing data will fail, as not optional
|
||||||
|
pol = MustConstruct(NotEqual(".[1]", literal.String("foo")))
|
||||||
|
ok, leaf = pol.Match(nd)
|
||||||
|
require.False(t, ok)
|
||||||
|
require.Equal(t, pol[0], leaf)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -418,11 +421,11 @@ func TestMatch(t *testing.T) {
|
|||||||
require.False(t, ok)
|
require.False(t, ok)
|
||||||
require.Equal(t, pol[0], leaf)
|
require.Equal(t, pol[0], leaf)
|
||||||
|
|
||||||
// TODO: clarify how it works on missing data
|
// missing data will fail, as not optional
|
||||||
pol = MustConstruct(Not(Equal(".foobar", literal.Bool(true))))
|
pol = MustConstruct(Not(Equal(".foobar", literal.Bool(true))))
|
||||||
ok, leaf = pol.Match(nd)
|
ok, leaf = pol.Match(nd)
|
||||||
require.True(t, ok)
|
require.False(t, ok)
|
||||||
require.Nil(t, leaf)
|
require.Equal(t, MustConstruct(Equal(".foobar", literal.Bool(true)))[0], leaf)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("conjunction", func(t *testing.T) {
|
t.Run("conjunction", func(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user