package hostactors import ( "reflect" "strings" "testing" ) func TestConsoleInvitationDoesNotAdmitOrRebind(t *testing.T) { ctx := t.Context() d, signer, before := fixture(t) c := Console{Enrollment: strings.Repeat("c", 32), InstanceID: "console-2", Namespaces: []string{"platform"}, DeploymentBucket: d.Bucket} for range 2 { if err := d.InviteConsole(ctx, signer, c); err != nil { t.Fatal(err) } } got, err := d.InvitedConsole(ctx, before, c.InstanceID) if err != nil || !reflect.DeepEqual(got, c) { t.Fatal("invitation identity changed", got, err) } changed := c changed.Enrollment = strings.Repeat("d", 32) if err := d.InviteConsole(ctx, signer, changed); err == nil { t.Fatal("rebound invitation") } changed = c changed.InstanceID = "../other" if err := d.InviteConsole(ctx, signer, changed); err == nil { t.Fatal("invalid console ID invited") } if _, err := d.InvitedConsole(ctx, before, "../other"); err == nil { t.Fatal("invalid console ID read") } after, err := d.Read(ctx) if err != nil || after.ETag != before.ETag { t.Fatal("invitation changed roster membership", err) } }