oficina / base Public

Make Ask's Disconnect the member's, on every device

Fable: the native app remembered Disconnect per device, but the Ask
connection is the member's, so the iPhone's next automatic set-up
(POST /api/v1/ask/oficina) undid a Disconnect made on the Mac or the
web.

Base now keeps members.ask_disconnected (migration 0012).

- Disconnect (the web's Settings and the app, both POST /ask/disconnect)
  sets it in the same transaction that removes the link and host token,
  inside changeLink. A Disconnect that fails sets nothing.
- Only an explicit connect clears it, in the transaction that saves the
  new link (SaveEquipoLink): the web's Connect or Reconnect, or a native
  set-up without "auto": true. An explicit set-up that fails leaves it
  set.
- POST /api/v1/ask/oficina takes an optional "auto" (boolean). With
  "auto": true while the flag is set it answers 409
  {"state":"disconnected"} and does nothing at Equipo or here. The flag
  and the connection generation are read together under the member's
  lock, so a Disconnect while an automatic set-up waits at Equipo still
  overtakes it (superseded), as before.
- /ask/state gains "disconnected": true|false. The web shows its usual
  connect state after Disconnect, as before.

Tests: a web Disconnect refuses the app's automatic set-up without
reaching Equipo, and an explicit one connects and clears it ("auto":
false counts as explicit); the web's Connect clears it and a failed
explicit set-up doesn't; it is per member; it is stored (read afresh
from the members table); a failed Disconnect leaves it unset; /ask and
Settings show Connect after Disconnect. The contract test and
docs/api/base-native-v1.md have the new field and answer.

make ci: 16 packages ran, 0 failed; test step 7.9s of 60s.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 4b1c58513b135c42f14e17af5a901c476c28f304 parent c49f6b4
9 files changed, +248 −17
  • docs/api/base-native-v1.md +21 −5
  • internal/store/equipo.go +18 −2
  • internal/store/members.go +6 −2
  • internal/store/migrations/0012_ask_disconnected.sql +4 −0
  • internal/web/ask.go +4 −1
  • internal/web/ask_connect.go +6 −3
  • internal/web/ask_oficina_native.go +20 −2
  • internal/webtest/ask_disconnect_test.go +167 −0
  • internal/webtest/ask_native_contract_test.go +2 −2
diff --git a/docs/api/base-native-v1.md b/docs/api/base-native-v1.md
index 9bc4f88..cfa319a 100644
--- a/docs/api/base-native-v1.md
+++ b/docs/api/base-native-v1.md
@@ -110,7 +110,8 @@ for a form). Every answer is `no-store`.
```json
{"state": "ready", "messages": [Message…], "jobs": [Job…], "cards": [Card…], "turn": Turn|null,
- "status": "Thinking…", "cursor": 42, "renew_after": "2026-11-28T10:00:00Z", "equipo_origin": "https://equipo.acme.example"}
+ "status": "Thinking…", "cursor": 42, "renew_after": "2026-11-28T10:00:00Z", "equipo_origin": "https://equipo.acme.example",
+ "disconnected": false}
```
- `messages`, `jobs` and `cards` are never `null`. Outside `ready`,
@@ -125,6 +126,10 @@ for a form). Every answer is `no-store`.
(below), silently. `""` for a key from the web's code flow, or none.
- `equipo_origin` is the Equipo instance Ask relays to: the audience of the
assertion for Ask set-up.
+- `disconnected` is `true` once the member has disconnected Ask, on any
+ device or the web, until they connect it themselves. While it is, no
+ client sets Ask up by itself; the app offers Connect instead. `state` is
+ then `connect`, as after any Disconnect.
**Message** `{"id", "role": "person"|"assistant", "text", "turn_id", "created_at"}`.
An assistant's `text` may carry the little Markdown `ask.js` draws (lists,
@@ -209,14 +214,24 @@ Form: `choice` (an option's `value`), `revision` (the card's, as seen) and
### `POST /ask/disconnect`
Ends the person's Ask connection, revoking the key in Equipo, whichever
-way it was made. It answers `303 /settings`.
+way it was made, and marks Ask disconnected by the member (`disconnected`
+in `/ask/state`), for every device and the web. It answers `303 /settings`.
+A Disconnect that fails changes nothing, the mark included.
+
+Only an explicit connect clears the mark, in the same step that saves the
+new connection: the web's Connect (or Reconnect), or
+`POST /api/v1/ask/oficina` without `"auto": true`. An explicit set-up that
+fails leaves it set.
## Ask set-up with Oficina ID
### `POST /api/v1/ask/oficina`
-JSON `{"assertion", "verifier"}`: an assertion the kit fetched from Oficina
-ID addressed to `equipo_origin`, and its verifier. Only a native session may
+JSON `{"assertion", "verifier", "auto"?}`: an assertion the kit fetched
+from Oficina ID addressed to `equipo_origin`, and its verifier. `auto` is
+`true` for a set-up the app starts by itself (after sign-in, or to renew
+after `renew_after`); leave it out, or send `false`, when the person asked
+to connect. Only a native session may
call it (with `Origin`, as every POST). Base completes Equipo's own native
sign-in for the person (Equipo's `POST /native/oficina-id`, then
`POST /api/v1/auth/devices/native`), keeps the key it gets sealed where the
@@ -227,10 +242,11 @@ anything else that changes the person's connection meanwhile.
| status | body | meaning |
|---|---|---|
| `200` | `{"state":"ready","renew_after":"<RFC 3339>"}` | Ask is ready. The key ends with Equipo's session, seven days after it was made; `renew_after` is five days after. After it, post a fresh assertion: that replaces the key and revokes the old one in Equipo. |
+| `409` | `{"state":"disconnected"}` | `auto` was `true`, and the member has disconnected Ask. Nothing was done, at Equipo or here. Show Connect; post again without `auto` only when the person asks. |
| `409` | `{"state":"not_linked"}` | Equipo has no member linked to this Oficina ID. Show Ask's "not set up for you yet" state, with the web's code flow; don't retry in a loop. |
| `409` | `{"state":"superseded"}` | Ask's connection changed while Equipo answered (Disconnect, or a connection from the web): nothing was saved, and the device Equipo made was revoked. Reload `/ask/state`; don't retry at once. |
| `422` | `{"state":"failed"}` | Equipo didn't accept the assertion (expired, wrong audience or verifier, already used). Get a fresh one and try once more. |
-| `400` | `{"state":"invalid"}` | Not JSON, an unknown or missing field, or Equipo couldn't read it. |
+| `400` | `{"state":"invalid"}` | Not JSON, an unknown or missing field (or `auto` not a boolean), or Equipo couldn't read it. |
| `403` | `{"state":"forbidden"}` | Not a native session: the web keeps its code flow. |
| `502` | `{"state":"unavailable"}` | Equipo didn't answer, or refused the device. Try again later. |
| `503` | `{"state":"unavailable"}` | Base couldn't read or store the connection. |
diff --git a/internal/store/equipo.go b/internal/store/equipo.go
index b00579b..37b8256 100644
--- a/internal/store/equipo.go
+++ b/internal/store/equipo.go
@@ -56,6 +56,7 @@ func EquipoLinkFor(ctx context.Context, db *sql.DB, memberID string) (l EquipoLi
// SaveEquipoLink stores l as the member's only link, replacing any other,
// and forgets the member's host token in the same transaction: a new
// connection may be another Equipo person, and gets its own once ready.
+// It is how the member connects Ask, so it also clears AskDisconnected.
func SaveEquipoLink(ctx context.Context, db *sql.DB, l EquipoLink) error {
var polled any
if l.PolledAt != nil {
@@ -65,6 +66,9 @@ func SaveEquipoLink(ctx context.Context, db *sql.DB, l EquipoLink) error {
if _, err := tx.ExecContext(ctx, `DELETE FROM host_tokens WHERE member_id = ?`, l.MemberID); err != nil {
return err
}
+ if _, err := tx.ExecContext(ctx, `UPDATE members SET ask_disconnected = 0 WHERE id = ?`, l.MemberID); err != nil {
+ return err
+ }
_, err := tx.ExecContext(ctx, `INSERT INTO equipo_links (`+equipoCols+`, updated_at)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
ON CONFLICT (member_id) DO UPDATE SET origin = excluded.origin, state = excluded.state,
@@ -156,17 +160,29 @@ func LoseEquipoLink(ctx context.Context, db *sql.DB, memberID, dev string) error
}
// DisconnectEquipo forgets the member's link, whichever device it is now,
-// and their host token, in one transaction: both go or neither does.
+// and their host token, and marks Ask disconnected by the member
+// (AskDisconnected), in one transaction: all three or none.
func DisconnectEquipo(ctx context.Context, db *sql.DB, memberID string) error {
return inTx(ctx, db, func(tx *sql.Tx) error {
if _, err := tx.ExecContext(ctx, `DELETE FROM equipo_links WHERE member_id = ?`, memberID); err != nil {
return err
}
- _, err := tx.ExecContext(ctx, `DELETE FROM host_tokens WHERE member_id = ?`, memberID)
+ if _, err := tx.ExecContext(ctx, `DELETE FROM host_tokens WHERE member_id = ?`, memberID); err != nil {
+ return err
+ }
+ _, err := tx.ExecContext(ctx, `UPDATE members SET ask_disconnected = 1 WHERE id = ?`, memberID)
return err
})
}
+// AskDisconnected reports whether the member has disconnected Ask and not
+// connected it since.
+func AskDisconnected(ctx context.Context, q QueryRower, memberID string) (bool, error) {
+ var v bool
+ err := q.QueryRowContext(ctx, `SELECT ask_disconnected FROM members WHERE id = ?`, memberID).Scan(&v)
+ return v, err
+}
+
// SetEquipoPerson records the Equipo address the member's device dev
// speaks for, if the link is still that device.
func SetEquipoPerson(ctx context.Context, db *sql.DB, memberID, dev, person string) error {
diff --git a/internal/store/members.go b/internal/store/members.go
index 3249d4e..7726f23 100644
--- a/internal/store/members.go
+++ b/internal/store/members.go
@@ -24,9 +24,13 @@ type Member struct {
// AskClosed is true once the member has closed Ask Base, docked open
// beside Home on a wide screen, until they open it again.
AskClosed bool
+ // AskDisconnected is true once the member has disconnected Ask Base,
+ // until they connect it themselves (DisconnectEquipo, SaveEquipoLink):
+ // no app sets it up again by itself meanwhile.
+ AskDisconnected bool
}
-const memberCols = `id, email, name, role, invited_at, joined_at, invite_sent_at, theme, ask_closed`
+const memberCols = `id, email, name, role, invited_at, joined_at, invite_sent_at, theme, ask_closed, ask_disconnected`
// memberColsOf is memberCols qualified by a table alias, for joins.
func memberColsOf(alias string) string {
@@ -42,7 +46,7 @@ type scanner interface{ Scan(...any) error }
func scanMember(s scanner) (Member, error) {
var m Member
var joined, sent sql.NullTime
- if err := s.Scan(&m.ID, &m.Email, &m.Name, &m.Role, &m.InvitedAt, &joined, &sent, &m.Theme, &m.AskClosed); err != nil {
+ if err := s.Scan(&m.ID, &m.Email, &m.Name, &m.Role, &m.InvitedAt, &joined, &sent, &m.Theme, &m.AskClosed, &m.AskDisconnected); err != nil {
return Member{}, err
}
if joined.Valid {
diff --git a/internal/store/migrations/0012_ask_disconnected.sql b/internal/store/migrations/0012_ask_disconnected.sql
new file mode 100644
index 0000000..a309682
--- /dev/null
+++ b/internal/store/migrations/0012_ask_disconnected.sql
@@ -0,0 +1,4 @@
+-- ask_disconnected: the member disconnected Ask Base, and no app connects
+-- it again by itself until they connect it themselves. Theirs, on every
+-- device.
+ALTER TABLE members ADD COLUMN ask_disconnected integer NOT NULL DEFAULT 0;
diff --git a/internal/web/ask.go b/internal/web/ask.go
index 7b06cf4..ea02167 100644
--- a/internal/web/ask.go
+++ b/internal/web/ask.go
@@ -570,8 +570,11 @@ func (a *app) askStateJSON(w http.ResponseWriter, r *http.Request) {
Cursor int64 `json:"cursor"`
RenewAfter string `json:"renew_after"`
EquipoOrigin string `json:"equipo_origin"`
+ // Disconnected: the member disconnected Ask, so no app sets it up
+ // again by itself.
+ Disconnected bool `json:"disconnected"`
}{v.State, append([]equipo.Message{}, v.Messages...), append([]jobView{}, v.Jobs...), append([]equipo.Card{}, v.Cards...), v.Turn, v.Status, cursor,
- renew, a.ask.client.Origin()}
+ renew, a.ask.client.Origin(), me.AskDisconnected}
writeJSON(w, http.StatusOK, out)
}
diff --git a/internal/web/ask_connect.go b/internal/web/ask_connect.go
index 5cded9b..3dd4963 100644
--- a/internal/web/ask_connect.go
+++ b/internal/web/ask_connect.go
@@ -383,12 +383,15 @@ func (a *app) changeLink(id string, change func() error) error {
return change()
}
-// linkGen is the member's connection generation now.
-func (a *app) linkGen(id string) uint64 {
+// linkGenDisconnected is the member's connection generation now, and
+// whether they have disconnected Ask, read together under their lock:
+// Disconnect sets the one and moves the other in one locked step.
+func (a *app) linkGenDisconnected(ctx context.Context, id string) (uint64, bool, error) {
c := a.memberConn(id)
c.mu.Lock()
defer c.mu.Unlock()
- return c.gen
+ disconnected, err := store.AskDisconnected(ctx, a.db, id)
+ return c.gen, disconnected, err
}
func (a *app) renderConnect(w http.ResponseWriter, r *http.Request, status int, v connectView) {
diff --git a/internal/web/ask_oficina_native.go b/internal/web/ask_oficina_native.go
index f489495..13032c7 100644
--- a/internal/web/ask_oficina_native.go
+++ b/internal/web/ask_oficina_native.go
@@ -51,6 +51,10 @@ const askNotLinked = "not_linked"
// saved nothing, and revoked the device it made.
const askSuperseded = "superseded"
+// askDisconnected is the answer to an automatic set-up after the member
+// disconnected Ask (store.Member.AskDisconnected): nothing was done.
+const askDisconnected = "disconnected"
+
// renewAfter is when the app should send a fresh assertion for link l,
// zero for a key from the code flow.
func renewAfter(l store.EquipoLink, sec deviceSecrets) time.Time {
@@ -81,6 +85,10 @@ func (a *app) askOficina(w http.ResponseWriter, r *http.Request) {
var in struct {
Assertion string `json:"assertion"`
Verifier string `json:"verifier"`
+ // Auto is a set-up the app starts by itself (after sign-in, or to
+ // renew), which yields to the member's Disconnect; without it the
+ // person asked, and it connects Ask again.
+ Auto bool `json:"auto"`
}
if !isJSONBody(r) || decodeStrict(http.MaxBytesReader(w, r.Body, 16<<10), &in) != nil ||
in.Assertion == "" || len(in.Assertion) > 8192 || in.Verifier == "" || len(in.Verifier) > 256 {
@@ -91,10 +99,20 @@ func (a *app) askOficina(w http.ResponseWriter, r *http.Request) {
ctx, cancel := context.WithTimeout(context.WithoutCancel(r.Context()), askOficinaTimeout)
defer cancel()
- // The connection as the set-up begins. Anything that changes it while
+ // The connection as the set-up begins, and whether the member has
+ // disconnected Ask, read together. Anything that changes it while
// Equipo answers (Disconnect, the web's Connect or its approval) wins:
// the set-up then saves nothing.
- gen := a.linkGen(me.ID)
+ gen, disconnected, err := a.linkGenDisconnected(ctx, me.ID)
+ if err != nil {
+ a.logger.Error("ask oficina: disconnected", "err", err)
+ writeJSON(w, http.StatusServiceUnavailable, map[string]string{"state": askUnavailable})
+ return
+ }
+ if in.Auto && disconnected {
+ writeJSON(w, http.StatusConflict, map[string]string{"state": askDisconnected})
+ return
+ }
sess, err := a.ask.client.NativeExchange(ctx, in.Assertion, in.Verifier)
if err != nil {
a.askOficinaRefused(w, "exchange", err)
diff --git a/internal/webtest/ask_disconnect_test.go b/internal/webtest/ask_disconnect_test.go
new file mode 100644
index 0000000..c0a1d1a
--- /dev/null
+++ b/internal/webtest/ask_disconnect_test.go
@@ -0,0 +1,167 @@
+package webtest
+
+import (
+ "context"
+ "encoding/json"
+ "net/http"
+ "strings"
+ "testing"
+
+ "amadan.net/carlos/base/internal/equipo/equipotest"
+ "amadan.net/carlos/base/internal/store"
+)
+
+// Disconnect is the member's, not a device's: once they disconnect Ask
+// anywhere, no app connects it again by itself. Only an explicit connect
+// (the web's Connect, or the app's set-up when the person asks) does.
+
+// connectAuto posts what the app posts when it sets Ask up by itself.
+func (a *testApp) connectAuto(f *equipotest.Fake, subject string) Resp {
+ a.t.Helper()
+ assertion, verifier := f.OficinaAssertion(subject)
+ body, _ := json.Marshal(map[string]any{"assertion": assertion, "verifier": verifier, "auto": true})
+ return a.nativePost("/api/v1/ask/oficina", string(body))
+}
+
+// askDisconnected is /ask/state's "disconnected".
+func (a *testApp) askDisconnected() bool {
+ a.t.Helper()
+ _, r := a.askState()
+ var s struct {
+ Disconnected *bool `json:"disconnected"`
+ }
+ if err := json.Unmarshal([]byte(r.Body), &s); err != nil || s.Disconnected == nil {
+ a.t.Fatalf("no disconnected in /ask/state: %s", r.Body)
+ }
+ return *s.Disconnected
+}
+
+// storedDisconnected is the flag as stored, read afresh: what a restarted
+// Base reads.
+func (a *testApp) storedDisconnected(email string) bool {
+ a.t.Helper()
+ m, ok, err := store.MemberByEmail(context.Background(), a.DB, email)
+ if err != nil || !ok {
+ a.t.Fatalf("member %s: %v", email, err)
+ }
+ return m.AskDisconnected
+}
+
+func TestDisconnectOnTheWebStopsAutomaticSetUp(t *testing.T) {
+ web, app, f := newNativeAskApp(t)
+ f.LinkOficinaID("subject-owner", ownerAddress)
+ if r := app.connectAuto(f, "subject-owner"); r.Code != 200 {
+ t.Fatalf("automatic set-up: %d %s", r.Code, r.Body)
+ }
+ if app.askDisconnected() {
+ t.Fatal("disconnected before any Disconnect")
+ }
+ if r := web.post("/ask/disconnect", nil); r.Code != 303 {
+ t.Fatalf("disconnect: %d", r.Code)
+ }
+ if !app.askDisconnected() || !app.storedDisconnected(ownerAddress) {
+ t.Fatal("Disconnect did not stick")
+ }
+ exchanges := len(f.Calls("/native/oficina-id"))
+ wantBody(t, "automatic set-up after Disconnect", app.connectAuto(f, "subject-owner"), 409, `{"state":"disconnected"}`)
+ if len(f.Calls("/native/oficina-id")) != exchanges || app.equipoLinks() != 0 {
+ t.Fatalf("an automatic set-up after Disconnect reached Equipo or stored a link")
+ }
+ if s, _ := app.askState(); s.State != "connect" {
+ t.Errorf("state: %s", s.State)
+ }
+ // The person asks for it: the explicit set-up connects and clears it.
+ if r := app.connectWithOficina(f, "subject-owner"); r.Code != 200 {
+ t.Fatalf("explicit set-up: %d %s", r.Code, r.Body)
+ }
+ if app.askDisconnected() || app.storedDisconnected(ownerAddress) {
+ t.Fatal("an explicit connect left the flag set")
+ }
+ if r := app.connectAuto(f, "subject-owner"); r.Code != 200 {
+ t.Fatalf("automatic renewal after reconnecting: %d %s", r.Code, r.Body)
+ }
+}
+
+// "auto": false is explicit.
+func TestExplicitSetUpSaysSo(t *testing.T) {
+ _, app, f := newNativeAskApp(t)
+ f.LinkOficinaID("subject-owner", ownerAddress)
+ app.connectWithOficina(f, "subject-owner")
+ app.post("/ask/disconnect", nil)
+ assertion, verifier := f.OficinaAssertion("subject-owner")
+ body, _ := json.Marshal(map[string]any{"assertion": assertion, "verifier": verifier, "auto": false})
+ if r := app.nativePost("/api/v1/ask/oficina", string(body)); r.Code != 200 {
+ t.Fatalf("auto false: %d %s", r.Code, r.Body)
+ }
+ wantBody(t, "auto not a boolean", app.nativePost("/api/v1/ask/oficina", `{"assertion":"x","verifier":"y","auto":"yes"}`), 400, `{"state":"invalid"}`)
+}
+
+// The web's Connect is explicit too, and an explicit set-up that fails
+// leaves the flag as it was.
+func TestWebConnectClearsDisconnected(t *testing.T) {
+ web, app, f := newNativeAskApp(t)
+ web.approveEquipo(f)
+ web.post("/ask/disconnect", nil)
+ f.FailNextNativeExchange(503)
+ if r := app.connectWithOficina(f, "subject-owner"); r.Code != 502 {
+ t.Fatalf("explicit set-up with Equipo down: %d %s", r.Code, r.Body)
+ }
+ if !app.askDisconnected() {
+ t.Fatal("a failed explicit set-up cleared the flag")
+ }
+ web.approveEquipo(f)
+ if app.askDisconnected() || app.storedDisconnected(ownerAddress) {
+ t.Fatal("the web's Connect left the flag set")
+ }
+}
+
+func TestDisconnectedIsPerMember(t *testing.T) {
+ web, app, f := newNativeAskApp(t)
+ if _, _, err := store.Invite(context.Background(), web.DB, "ana@acme.test"); err != nil {
+ t.Fatal(err)
+ }
+ web.newBrowser().link("ana@acme.test", "subject-ana")
+ ana := web.nativeSignIn("subject-ana")
+ f.LinkOficinaID("subject-owner", ownerAddress)
+ f.LinkOficinaID("subject-ana", "ana@acme.test")
+ app.connectWithOficina(f, "subject-owner")
+ if r := app.post("/ask/disconnect", nil); r.Code != 303 {
+ t.Fatalf("disconnect from the app: %d", r.Code)
+ }
+ if ana.askDisconnected() || web.storedDisconnected("ana@acme.test") {
+ t.Fatal("the owner's Disconnect reached Ana")
+ }
+ if r := ana.connectAuto(f, "subject-ana"); r.Code != 200 {
+ t.Fatalf("Ana's automatic set-up: %d %s", r.Code, r.Body)
+ }
+ wantBody(t, "the owner's", app.connectAuto(f, "subject-owner"), 409, `{"state":"disconnected"}`)
+}
+
+// A Disconnect that fails leaves the flag as it was.
+func TestFailedDisconnectLeavesNoFlag(t *testing.T) {
+ web, app, f := newNativeAskApp(t)
+ web.approveEquipo(f)
+ if _, err := web.DB.Exec(`CREATE TRIGGER keep_link BEFORE DELETE ON equipo_links BEGIN SELECT RAISE(ABORT, 'injected'); END`); err != nil {
+ t.Fatal(err)
+ }
+ if r := web.post("/ask/disconnect", nil); r.Code == 303 {
+ t.Fatal("Disconnect reported success")
+ }
+ if app.askDisconnected() || web.storedDisconnected(ownerAddress) {
+ t.Fatal("a failed Disconnect set the flag")
+ }
+}
+
+// The web shows what it always showed after Disconnect: the connect state.
+func TestWebAfterDisconnectShowsConnect(t *testing.T) {
+ web, _, f := newNativeAskApp(t)
+ web.approveEquipo(f)
+ web.post("/ask/disconnect", nil)
+ page := web.get("/ask")
+ if page.Code != 200 || !strings.Contains(page.Body, `action="/ask/connect"`) {
+ t.Fatalf("/ask after Disconnect: %d\n%s", page.Code, page.Body)
+ }
+ if r := web.get("/settings"); r.Code != http.StatusOK || !strings.Contains(r.Body, `action="/ask/connect"`) {
+ t.Fatalf("Settings after Disconnect: %d", r.Code)
+ }
+}
diff --git a/internal/webtest/ask_native_contract_test.go b/internal/webtest/ask_native_contract_test.go
index be42266..bf87478 100644
--- a/internal/webtest/ask_native_contract_test.go
+++ b/internal/webtest/ask_native_contract_test.go
@@ -100,13 +100,13 @@ func (a *testApp) askState() (askState, Resp) {
return s, r
}
-var stateKeys = []string{"state", "messages", "jobs", "cards", "turn", "status", "cursor", "renew_after", "equipo_origin"}
+var stateKeys = []string{"state", "messages", "jobs", "cards", "turn", "status", "cursor", "renew_after", "equipo_origin", "disconnected"}
func TestAskContractBeforeConnecting(t *testing.T) {
_, app, f := newNativeAskApp(t)
s, r := app.askState()
wantKeys(t, "state", r.Body, stateKeys...)
- if strings.TrimSpace(r.Body) != `{"state":"connect","messages":[],"jobs":[],"cards":[],"turn":null,"status":"","cursor":0,"renew_after":"","equipo_origin":"`+f.URL+`"}` || s.State != "connect" {
+ if strings.TrimSpace(r.Body) != `{"state":"connect","messages":[],"jobs":[],"cards":[],"turn":null,"status":"","cursor":0,"renew_after":"","equipo_origin":"`+f.URL+`","disconnected":false}` || s.State != "connect" {
t.Errorf("not connected: %s", r.Body)
}
wantBody(t, "send", app.nativeForm("/ask/messages", url.Values{"text": {"Hello"}, "key": {"k1"}}), 409, `{"state":"connect"}`)