carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1package host
2
3import (
4 "context"
5 "errors"
6 "github.com/carlosframework/platform/internal/hostclaim"
7 "testing"
8)
9
10func TestPlan12LocalParkUsesOwnerAndRechecksIdentity(t *testing.T) {
11 identityErr := error(nil)
12 calls := 0
13 sentinel := errors.New("owner")
14 local := claimMoveLocalAuthorizer(func(context.Context) error { return identityErr }, func(_ context.Context, o hostclaim.Observed, ob hostclaim.Obligation) error {
15 calls++
16 if o.Host != "app.example" || ob.Park != nil || ob.Kind != "park-local" {
17 t.Fatal("wrong owner input")
18 }
19 return sentinel
20 })
21 c := &hostclaim.Claim{Host: "app.example"}
22 ob := hostclaim.Obligation{Kind: "park-local"}
23 if err := local(t.Context(), c, ob); !errors.Is(err, sentinel) || calls != 1 {
24 t.Fatal(err, calls)
25 }
26 identityErr = errors.New("enrollment changed")
27 if err := local(t.Context(), c, ob); !errors.Is(err, identityErr) || calls != 1 {
28 t.Fatal(err, calls)
29 }
30}
31