carlos / platform Public

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

Plain git — no account needed to clone.

Download

Download this file

1package hostactors
2
3import (
4 "reflect"
5 "strings"
6 "testing"
7)
8
9func TestConsoleInvitationDoesNotAdmitOrRebind(t *testing.T) {
10 ctx := t.Context()
11 d, signer, before := fixture(t)
12 c := Console{Enrollment: strings.Repeat("c", 32), InstanceID: "console-2", Namespaces: []string{"platform"}, DeploymentBucket: d.Bucket}
13 for range 2 {
14 if err := d.InviteConsole(ctx, signer, c); err != nil {
15 t.Fatal(err)
16 }
17 }
18 got, err := d.InvitedConsole(ctx, before, c.InstanceID)
19 if err != nil || !reflect.DeepEqual(got, c) {
20 t.Fatal("invitation identity changed", got, err)
21 }
22 changed := c
23 changed.Enrollment = strings.Repeat("d", 32)
24 if err := d.InviteConsole(ctx, signer, changed); err == nil {
25 t.Fatal("rebound invitation")
26 }
27 changed = c
28 changed.InstanceID = "../other"
29 if err := d.InviteConsole(ctx, signer, changed); err == nil {
30 t.Fatal("invalid console ID invited")
31 }
32 if _, err := d.InvitedConsole(ctx, before, "../other"); err == nil {
33 t.Fatal("invalid console ID read")
34 }
35 after, err := d.Read(ctx)
36 if err != nil || after.ETag != before.ETag {
37 t.Fatal("invitation changed roster membership", err)
38 }
39}
40