@@ -1,14 +1,11 @@
|
|||||||
package policy
|
package policy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/ipld/go-ipld-prime"
|
"github.com/ipld/go-ipld-prime"
|
||||||
"github.com/ipld/go-ipld-prime/codec/dagjson"
|
"github.com/ipld/go-ipld-prime/codec/dagjson"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/ucan-wg/go-ucan/pkg/policy/literal"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestIpldRoundTrip(t *testing.T) {
|
func TestIpldRoundTrip(t *testing.T) {
|
||||||
@@ -65,19 +62,3 @@ func TestIpldRoundTrip(t *testing.T) {
|
|||||||
require.JSONEq(t, tc.dagJsonStr, string(wroteAsDagJson))
|
require.JSONEq(t, tc.dagJsonStr, string(wroteAsDagJson))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFoo(t *testing.T) {
|
|
||||||
fmt.Println(MustConstruct(
|
|
||||||
And(
|
|
||||||
Equal(".foo1", literal.String(".bar1")),
|
|
||||||
NotEqual(".foo2", literal.String(".bar2")),
|
|
||||||
),
|
|
||||||
Or(
|
|
||||||
GreaterThan(".foo5", literal.Float(5.2)),
|
|
||||||
GreaterThanOrEqual(".foo6", literal.Float(6.2)),
|
|
||||||
),
|
|
||||||
Not(Like(".foo7", "*@example.com")),
|
|
||||||
All(".foo8", LessThan(".foo3", literal.Int(3))),
|
|
||||||
Any(".foo9", LessThanOrEqual(".foo4", literal.Int(4))),
|
|
||||||
))
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -59,6 +59,9 @@ type Token struct {
|
|||||||
|
|
||||||
// New creates an invocation Token with the provided options.
|
// New creates an invocation Token with the provided options.
|
||||||
//
|
//
|
||||||
|
// The given proofs MUST be ordered from the leaf (matching the invocation) to
|
||||||
|
// the root delegation.
|
||||||
|
//
|
||||||
// If no nonce is provided, a random 12-byte nonce is generated. Use the
|
// If no nonce is provided, a random 12-byte nonce is generated. Use the
|
||||||
// WithNonce or WithEmptyNonce options to specify provide your own nonce
|
// WithNonce or WithEmptyNonce options to specify provide your own nonce
|
||||||
// or to leave the nonce empty respectively.
|
// or to leave the nonce empty respectively.
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ func (t *Token) verifyProofs(delegations []*delegation.Token) error {
|
|||||||
sub = t.audience
|
sub = t.audience
|
||||||
}
|
}
|
||||||
|
|
||||||
// control from the invocation to the root
|
// control from the invocation to the root delegation
|
||||||
for i, dlgCid := range t.proof {
|
for i, dlgCid := range t.proof {
|
||||||
dlg := delegations[i]
|
dlg := delegations[i]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user