oficina / home Public

Merge branch 'native/equipo-in-directory' into main

claude agent, operated by paul@keymail.dev fd6edc20d580b33654d518e502b05fae9fd2d07b parent 17cdcafparent 3d1bc36
10 files changed, +232 −11
  • docs/superpowers/specs/2026-11-14-oficina-id-native.md +1 −1
  • implementation/equipo-native-mutations.json +38 −0
  • implementation/equipo-native-validation.md +39 −0
  • implementation/existing-team-adoption.md +7 −5
  • internal/home/app_chooser_test.go +1 −1
  • internal/home/directory_native.go +2 −2
  • internal/home/directory_runtime.go +1 −0
  • internal/home/directory_runtime_test.go +1 −1
  • internal/home/directorydata/canonical.go +1 −1
  • internal/home/equipo_native_test.go +141 −0

CI failed — run details

CI log
amadan: .amadan/timeout: this job's budget is 20m0s (this runner allows up to 30m0s)
=== vet ===
CGO_ENABLED=0 go vet ./...
CGO_ENABLED=0 go vet -tags browser ./internal/home/
cd handoff && CGO_ENABLED=0 go vet ./...
cd roster && CGO_ENABLED=0 go vet ./...
cd dashboard && CGO_ENABLED=0 go vet ./...
cd connect && CGO_ENABLED=0 go vet ./...
cd teammode && CGO_ENABLED=0 go vet ./...
=== fmt ===
=== build ===
CGO_ENABLED=0 go build ./...
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build ./cmd/home ./cmd/oficina ./internal/operatorlaunch
cd handoff && CGO_ENABLED=0 go build ./...
cd roster && CGO_ENABLED=0 go build ./...
cd dashboard && CGO_ENABLED=0 go build ./...
cd connect && CGO_ENABLED=0 go build ./...
cd teammode && CGO_ENABLED=0 go build ./...
=== go-test ===
CGO_ENABLED=0 go test -count=1 ./...
?   	amadan.net/oficina/home/cmd/home	[no test files]
ok  	amadan.net/oficina/home/cmd/home-placeholder	0.876s
?   	amadan.net/oficina/home/cmd/oficina	[no test files]
ok  	amadan.net/oficina/home/internal/guardstest	0.162s
ok  	amadan.net/oficina/home/internal/home	51.661s
ok  	amadan.net/oficina/home/internal/home/directorydata	1.390s
ok  	amadan.net/oficina/home/internal/home/logtest	0.004s
ok  	amadan.net/oficina/home/internal/home/seal	0.002s
ok  	amadan.net/oficina/home/internal/home/sealtest	0.003s
ok  	amadan.net/oficina/home/internal/home/wisp	0.044s
ok  	amadan.net/oficina/home/internal/operator	6.467s
ok  	amadan.net/oficina/home/internal/operatorlaunch	4.123s
ok  	amadan.net/oficina/home/internal/provisioner	49.804s
cd handoff && CGO_ENABLED=0 go test -count=1 ./...
ok  	amadan.net/oficina/home/handoff	0.656s
ok  	amadan.net/oficina/home/handoff/seal	0.002s
cd roster && CGO_ENABLED=0 go test -count=1 ./...
ok  	amadan.net/oficina/home/roster	5.120s
cd dashboard && CGO_ENABLED=0 go test ./...
ok  	amadan.net/oficina/home/dashboard	(cached)
cd connect && CGO_ENABLED=0 go test -count=1 ./...
ok  	amadan.net/oficina/home/connect	1.399s
ok  	amadan.net/oficina/home/connect/linkstore	0.459s
cd teammode && CGO_ENABLED=0 go test -count=1 ./...
ok  	amadan.net/oficina/home/teammode	0.099s
?   	amadan.net/oficina/home/teammode/teammodetest	[no test files]
=== race ===
go test -race -count=1 ./internal/home/ ./internal/operator/ ./internal/operatorlaunch/ ./internal/home/directorydata/
--- FAIL: TestOperatorCommandActualBinaryDispatch (2.20s)
    operator_command_linux_test.go:448: real binary dispatch failed 2 true
FAIL
FAIL	amadan.net/oficina/home/internal/home	318.332s
ok  	amadan.net/oficina/home/internal/operator	82.622s
ok  	amadan.net/oficina/home/internal/operatorlaunch	22.388s
ok  	amadan.net/oficina/home/internal/home/directorydata	23.583s
FAIL
make: *** [Makefile:133: test-race] Error 1

amadan: step race failed: exit status 2

amadan: job failed at step race — its output is above, not at the tail of this log
diff --git a/docs/superpowers/specs/2026-11-14-oficina-id-native.md b/docs/superpowers/specs/2026-11-14-oficina-id-native.md
index 35c177b..f4ff5b8 100644
--- a/docs/superpowers/specs/2026-11-14-oficina-id-native.md
+++ b/docs/superpowers/specs/2026-11-14-oficina-id-native.md
@@ -157,7 +157,7 @@ The browser `Finish` keeps today's shape (`handoff/http.go` `Finish`: `Store.Fin
## 9. Teams, store, onboarding
-**Teams.** The directory is a consumer. The app gets a directory session through `NativeExchange`, then calls `GET https://oficina.works/api/native/teams` → `[{sqid, label, name, role, apps:[{app, origin, consumer_id}]}]`. The list comes from `Store.AgentChoices`, filtered to live instances of the five apps, and is `no-store`. Apps use the returned origin as given. They never use portero. The app refreshes at launch, on opening the menu (at most every 5 minutes), and on any 403. The team colour is derived on the device from `sqid`. **Zero teams (Paul's ruling H):** once Alta runs, the empty state offers "Create a team" through Alta. While Alta is blocked, slice A shows help text only. Slice A needs Paul's teams to exist first, through Alta or the operator path.
+**Teams.** The directory is a consumer. The app gets a directory session through `NativeExchange`, then calls `GET https://oficina.works/api/native/teams` → `[{sqid, label, name, role, apps:[{app, origin, consumer_id}]}]`. The list comes from `Store.AgentChoices`, filtered to live instances of the six native apps (Equipo added by Paul’s approved 2026-11-20 Equipo native Oficina ID spec, part 3 / E4), and is `no-store`. Apps use the returned origin as given. They never use portero. The app refreshes at launch, on opening the menu (at most every 5 minutes), and on any 403. The team colour is derived on the device from `sqid`. **Zero teams (Paul's ruling H):** once Alta runs, the empty state offers "Create a team" through Alta. While Alta is blocked, slice A shows help text only. Slice A needs Paul's teams to exist first, through Alta or the operator path.
**Store (RastrilloApple).** Every record carries `v`. An older app reads what it understands, never rewrites a newer record, and asks for an update. **Shared keychain group:** each identity's record, key, token and **team cache**. Team names stay out of the Mac App Group because an unsandboxed app's group container is readable by any process running as the same user. **App Group** (`9U4A84C4WK.works.oficina` on Mac, `group.works.oficina` on iOS): identity order and the last-used (identity, team) only. **Each app's private keychain:** its sessions, keyed `(grant_id, origin)`.
diff --git a/implementation/equipo-native-mutations.json b/implementation/equipo-native-mutations.json
new file mode 100644
index 0000000..d1accee
--- /dev/null
+++ b/implementation/equipo-native-mutations.json
@@ -0,0 +1,38 @@
+[
+ {
+ "mutation": "remove-integrated-app",
+ "test": "TestEquipoDirectoryRoutes",
+ "result": "killed",
+ "output": "--- FAIL: TestEquipoDirectoryRoutes (0.00s)\n equipo_native_test.go:24: Equipo missing from integrated registry\n equipo_native_test.go:33: Equipo route refused: {TeamID:0 TeamSQID: Label:blue App:equipo Origin:https://blue.equipo.oficina.works ConsumerID:blue-equipo}\nFAIL\nFAIL\tamadan.net/oficina/home/internal/home\t0.374s\nFAIL"
+ },
+ {
+ "mutation": "remove-canonical-mapping",
+ "test": "TestEquipoDirectoryRoutes",
+ "result": "killed",
+ "output": "--- FAIL: TestEquipoDirectoryRoutes (0.00s)\n equipo_native_test.go:33: Equipo route refused: {TeamID:0 TeamSQID: Label:oficina App:equipo Origin:https://equipo.oficina.works ConsumerID:equipo}\n equipo_native_test.go:43: Equipo canonical origin missing\nFAIL\nFAIL\tamadan.net/oficina/home/internal/home\t0.367s\nFAIL"
+ },
+ {
+ "mutation": "remove-native-filter-entry",
+ "test": "TestNativeDirectoryEquipoLiveMembership",
+ "result": "killed",
+ "output": "--- FAIL: TestNativeDirectoryEquipoLiveMembership (0.08s)\n equipo_native_test.go:94: Equipo teams: []\nFAIL\nFAIL\tamadan.net/oficina/home/internal/home\t0.459s\nFAIL"
+ },
+ {
+ "mutation": "admit-pending-and-disabled",
+ "test": "TestNativeDirectoryEquipoLiveMembership",
+ "result": "killed",
+ "output": "--- FAIL: TestNativeDirectoryEquipoLiveMembership (0.08s)\n equipo_native_test.go:94: teams: 503 {\"error\":\"unavailable\"}\nFAIL\nFAIL\tamadan.net/oficina/home/internal/home\t0.445s\nFAIL"
+ },
+ {
+ "mutation": "admit-non-native-apps",
+ "test": "TestNativeDirectoryEquipoLiveMembership",
+ "result": "killed",
+ "output": "--- FAIL: TestNativeDirectoryEquipoLiveMembership (0.08s)\n equipo_native_test.go:94: Equipo teams: [{SQID:AAA111 Label:oficina Name:Oficina Role:member Apps:[{App:slides Origin:https://slides.oficina.works ConsumerID:slides}]} {SQID:BBB222 Label:blue Name:Blue Role:member Apps:[{App:equipo Origin:https://blue.equipo.oficina.works ConsumerID:blue-equipo}]}]\nFAIL\nFAIL\tamadan.net/oficina/home/internal/home\t0.460s\nFAIL"
+ },
+ {
+ "mutation": "admit-unregistered-equipo-origin",
+ "test": "TestNativeAssertEquipoRegisteredOrigins",
+ "result": "killed",
+ "output": "--- FAIL: TestNativeAssertEquipoRegisteredOrigins (0.06s)\n equipo_native_test.go:138: unregistered Equipo admitted: https://green.equipo.oficina.works 200\nFAIL\nFAIL\tamadan.net/oficina/home/internal/home\t0.442s\nFAIL"
+ }
+]
diff --git a/implementation/equipo-native-validation.md b/implementation/equipo-native-validation.md
new file mode 100644
index 0000000..53aa51e
--- /dev/null
+++ b/implementation/equipo-native-validation.md
@@ -0,0 +1,39 @@
+# Equipo native directory — validation, 2026-11-20
+
+Implementer: Codex GPT-6-Astra. Authority: Equipo's approved
+2026-11-20 native Oficina ID spec, parts 3–4 (E4).
+
+Tests were written first. Before implementation, `TestEquipoDirectoryRoutes`
+failed on the missing integrated registry and both routes/canonical mapping;
+`TestNativeDirectoryEquipoLiveMembership` returned an empty list. The
+assertion test already passed: the existing exact-origin consumer policy
+needs no production change.
+
+`make test` passed: vet, formatting, portable and linux/arm64 builds, all
+module tests and race checks. The Linux-only provisioner checks run in CI.
+No browser checks are needed: neither markup, styles nor framework pins moved.
+
+The new tests exercise canonical and team-host Equipo routes, exact app,
+origin and consumer ID output, pending/disabled/foreign-team exclusion,
+membership removal, and exclusion of live Slides from the native list.
+Assertions cover the canonical env consumer and an active table consumer;
+retired, unregistered, port, case, suffix and path variants are refused.
+
+Six deliberate mutations were killed by named behavioral tests, with their
+failure output in `equipo-native-mutations.json`. Every mutation was restored.
+No schema or native assertion policy changed.
+
+Deployment and operator work remain separate. The matching Alta branch
+`native/equipo-adoption` carries the rollout and Equipo contract notes.
+Neither branch is a deployment approval or a completed canary review.
+
+Read-only production checks on 2026-11-20 found Equipo absent from the
+effective env consumer manifest. Native assertion still refuses that origin
+until the operator adds `equipo: https://equipo.oficina.works` and restarts
+the credential service, as the Alta runbook describes. The existing web
+consumer implementation alone does not establish a deployed registration.
+
+Independent code review: Claude Fable 5.2, 2026-11-20, found no
+production-code blockers and independently passed both repositories' gates.
+Its required spec-count amendments are included here. The chooser test also
+covers Equipo's mounted web routes. Deployed canary review remains pending.
diff --git a/implementation/existing-team-adoption.md b/implementation/existing-team-adoption.md
index 5b5b9db..b1053a2 100644
--- a/implementation/existing-team-adoption.md
+++ b/implementation/existing-team-adoption.md
@@ -7,9 +7,11 @@ Base: d82341c. Amended 2026-11-16 for 522 Plan 1 digests and the Plan 2
waiver (see the observation recipe). Amended 2026-11-17 (Paul, discussion
103): the waiver's delivery evidence is the runner's automated check, and
the negative live checks are dropped for this adoption. Implements
-agent-access task 5 and Home discussion 103.
+agent-access task 5 and Home discussion 103. Amended 2026-11-20 by Paul’s
+approved Equipo native Oficina ID spec, part 3 / E4: Equipo joins canonical
+adoption as the seventh app; its app-side contract must be deployed first.
-The six existing canonical instances need directory membership and routing
+The seven existing canonical instances need directory membership and routing
without creating replacement instances, changing their keys, or converting
their existing item permissions to TeamMode. Agent adapters already support
this combination: Home controls delegated team admission; each app resolves
@@ -20,7 +22,7 @@ directory membership never grants access to existing content by itself.
Extend the signed operator plan with optional `existing_team` (the actual
team SQID, not the dashboard label). It is valid only for create-team or
-add-apps plans and only for the six compiled canonical apps. Both roles show
+add-apps plans and only for the seven compiled canonical apps. Both roles show
an explicit existing-app adoption description. The directory requires label
`oficina`, shows the exact canonical hosts, and binds seeding and every
subsequent operation to the plan's SQID. The credential plan binds owner-seed
@@ -277,7 +279,7 @@ revocation is covered by Home's and oficina-connect's own tests. As with
the Plan 2 waiver, this is not a precedent for any other adoption.
What stays: Plan A's two fresh confirmations, and the Calendar canary.
-Plan B activates calendar alone. Plan C, the other five apps, is gated
+Plan B activates calendar alone. Plan C, the other six apps, is gated
only on Plan B having activated calendar successfully, and stays refused
if calendar has since been rolled back or disabled. Synthetic proof of
refusal and revocation stays in integration tests. Until the reviewed
@@ -299,7 +301,7 @@ introduced for the adoption tool.
This supersedes team-provisioning-amendment.md §4's label.app-only rendering
for adoption plans, §2.6/§5's new-instance activation policy, and §8's claim
that a confirmed provisioner cannot affect existing canonical hosts. An
-adoption window explicitly allows binding those six pre-existing hosts to
+adoption window explicitly allows binding those seven pre-existing hosts to
one confirmed team, changing directory discovery and delegated admission.
It grants no local content permission and cannot change credential env
registrations, existing storage or keys. The operator signer can falsely
diff --git a/internal/home/app_chooser_test.go b/internal/home/app_chooser_test.go
index fc2bf1d..fc50f6a 100644
--- a/internal/home/app_chooser_test.go
+++ b/internal/home/app_chooser_test.go
@@ -8,7 +8,7 @@ import (
)
func TestNativeAppChoicesKeepTeamAndAppBoundaries(t *testing.T) {
- for _, app := range []string{"docs", "sheets", "slides", "calendar", "calls", "memoria"} {
+ for _, app := range []string{"docs", "sheets", "slides", "calendar", "calls", "memoria", "equipo"} {
t.Run(app, func(t *testing.T) {
f := newMountedChooser(t)
cookie := f.session(t, chooserPerson)
diff --git a/internal/home/directory_native.go b/internal/home/directory_native.go
index efa8fbd..6cfa3a1 100644
--- a/internal/home/directory_native.go
+++ b/internal/home/directory_native.go
@@ -32,7 +32,7 @@ const (
)
// nativeTeamApps are the native apps; the list is filtered to them (§9).
-var nativeTeamApps = map[string]bool{"calls": true, "docs": true, "sheets": true, "calendar": true, "memoria": true}
+var nativeTeamApps = map[string]bool{"calls": true, "docs": true, "sheets": true, "calendar": true, "memoria": true, "equipo": true}
// directoryNativeExchange is POST /native/oficina-id {assertion, verifier,
// target?, choice?}. It verifies the assertion against the pinned keys with
@@ -157,7 +157,7 @@ type nativeTeam struct {
}
// directoryNativeTeams is GET /api/native/teams: the person's teams with
-// live instances of the five native apps, from Store.AgentChoices. Zero
+// live instances of the six native apps, from Store.AgentChoices. Zero
// teams is an empty list, never an error; the app then shows its help and
// may link noTeamsHelpPath.
func (a *App) directoryNativeTeams(w http.ResponseWriter, r *http.Request) {
diff --git a/internal/home/directory_runtime.go b/internal/home/directory_runtime.go
index ddffc69..8d54e4a 100644
--- a/internal/home/directory_runtime.go
+++ b/internal/home/directory_runtime.go
@@ -21,6 +21,7 @@ func directoryApps() []directoryApp {
{slug: "calendar", name: "Calendar", integrated: true},
{slug: "calls", name: "Calls", integrated: true},
{slug: "memoria", name: "Memoria", integrated: true},
+ {slug: "equipo", name: "Equipo", integrated: true},
}
}
diff --git a/internal/home/directory_runtime_test.go b/internal/home/directory_runtime_test.go
index f4e4d20..193bd61 100644
--- a/internal/home/directory_runtime_test.go
+++ b/internal/home/directory_runtime_test.go
@@ -122,7 +122,7 @@ func TestDirectoryRuntimeAnonymousReturnAndRoleSchemaSeparation(t *testing.T) {
}
}
apps := directoryApps()
- if len(apps) != 6 || apps[0].slug != "docs" || !apps[0].integrated || apps[0].provisionable || apps[0].foreignOrigin != "" {
+ if len(apps) != 7 || apps[0].slug != "docs" || !apps[0].integrated || apps[0].provisionable || apps[0].foreignOrigin != "" {
t.Fatal("registry advertised unsupported provisioning")
}
for _, app := range apps {
diff --git a/internal/home/directorydata/canonical.go b/internal/home/directorydata/canonical.go
index 47fdad9..9e84bdf 100644
--- a/internal/home/directorydata/canonical.go
+++ b/internal/home/directorydata/canonical.go
@@ -4,7 +4,7 @@ package directorydata
// does not authorize a write: only a confirmed operator adoption may bind one.
func CanonicalOrigin(app string) string {
switch app {
- case "docs", "sheets", "slides", "memoria", "calendar", "calls":
+ case "docs", "sheets", "slides", "memoria", "calendar", "calls", "equipo":
return "https://" + app + ".oficina.works"
}
return ""
diff --git a/internal/home/equipo_native_test.go b/internal/home/equipo_native_test.go
new file mode 100644
index 0000000..4b6708a
--- /dev/null
+++ b/internal/home/equipo_native_test.go
@@ -0,0 +1,141 @@
+package home
+
+import (
+ "context"
+ "encoding/json"
+ "net/http"
+ "net/http/httptest"
+ "testing"
+ "time"
+
+ "amadan.net/oficina/home/internal/home/directorydata"
+ "amadan.net/rastrillo/rastrillo/migrate"
+ "amadan.net/rastrillo/rastrillo/sessions"
+)
+
+func TestEquipoDirectoryRoutes(t *testing.T) {
+ found := false
+ for _, app := range directoryApps() {
+ if app.slug == "equipo" {
+ found = app.name == "Equipo" && app.integrated && !app.provisionable && app.foreignOrigin == ""
+ }
+ }
+ if !found {
+ t.Error("Equipo missing from integrated registry")
+ }
+ for _, label := range []string{"oficina", "blue"} {
+ origin, consumer := "https://blue.equipo.oficina.works", "blue-equipo"
+ if label == "oficina" {
+ origin, consumer = "https://equipo.oficina.works", "equipo"
+ }
+ route := directorydata.Route{Label: label, App: "equipo", Origin: origin, ConsumerID: consumer}
+ if !directoryRouteAllowed(route) {
+ t.Errorf("Equipo route refused: %+v", route)
+ }
+ for _, bad := range []string{origin + "/", origin + ":443", origin + ".evil.invalid", "https://other.equipo.oficina.works"} {
+ route.Origin = bad
+ if directoryRouteAllowed(route) {
+ t.Errorf("unsafe Equipo route admitted: %+v", route)
+ }
+ }
+ }
+ if directorydata.CanonicalOrigin("equipo") != "https://equipo.oficina.works" {
+ t.Error("Equipo canonical origin missing")
+ }
+ for _, r := range []directorydata.Route{
+ {Label: "other", App: "equipo", ConsumerID: "equipo", Origin: "https://equipo.oficina.works"},
+ {Label: "oficina", App: "equipo", ConsumerID: "other", Origin: "https://equipo.oficina.works"},
+ {Label: "oficina", App: "unknown", ConsumerID: "unknown", Origin: "https://unknown.oficina.works"},
+ } {
+ if directoryRouteAllowed(r) {
+ t.Errorf("canonical binding widened: %+v", r)
+ }
+ }
+}
+
+func TestNativeDirectoryEquipoLiveMembership(t *testing.T) {
+ f := newMountedChooser(t)
+ rec := httptest.NewRecorder()
+ req := httptest.NewRequest("GET", directoryOrigin+"/", nil)
+ if err := f.p.directory.sessions.SignIn(rec, req, sessions.Session{Subject: chooserPerson, Method: nativeSessionMethod, AuthTime: time.Now()}); err != nil {
+ t.Fatal(err)
+ }
+ cookie := sessionCookie(rec)
+ exec := func(q string, args ...any) {
+ t.Helper()
+ if _, err := f.p.directory.db.Writer().Exec(q, args...); err != nil {
+ t.Fatal(err)
+ }
+ }
+ canonical := f.team(t, "AAA111", "oficina", "Oficina", chooserPerson)
+ team := f.team(t, "BBB222", "blue", "Blue", chooserPerson)
+ foreign := f.team(t, "CCC333", "other", "Other", chooserOther)
+ // Keep a live, non-native Slides instance to pin the native-only filter.
+ exec("UPDATE team_instances SET state='disabled'")
+ exec("INSERT INTO team_instances VALUES(?,?,?,?,?)", canonical, "slides", "https://slides.oficina.works", "slides", "live")
+ exec("INSERT INTO team_instances VALUES(?,?,?,?,?)", canonical, "equipo", "https://equipo.oficina.works", "equipo", "pending")
+ exec("INSERT INTO team_instances VALUES(?,?,?,?,?)", team, "equipo", "https://blue.equipo.oficina.works", "blue-equipo", "live")
+ exec("INSERT INTO team_instances VALUES(?,?,?,?,?)", foreign, "equipo", "https://other.equipo.oficina.works", "other-equipo", "live")
+ read := func() []nativeTeam {
+ t.Helper()
+ w := directoryCall(t, f, http.MethodGet, nativeTeamsPath, "", cookie, nil)
+ var got []nativeTeam
+ if w.Code != 200 || json.Unmarshal(w.Body.Bytes(), &got) != nil {
+ t.Fatalf("teams: %d %s", w.Code, w.Body.String())
+ }
+ return got
+ }
+ check := func(got []nativeTeam, sqid, label, name, origin, consumer string) {
+ t.Helper()
+ if len(got) != 1 || got[0].SQID != sqid || got[0].Label != label || got[0].Name != name || got[0].Role != "member" || len(got[0].Apps) != 1 || got[0].Apps[0] != (nativeTeamApp{"equipo", origin, consumer}) {
+ t.Fatalf("Equipo teams: %+v", got)
+ }
+ }
+ check(read(), "BBB222", "blue", "Blue", "https://blue.equipo.oficina.works", "blue-equipo")
+ exec("UPDATE team_instances SET state='disabled' WHERE team_id=? AND app='equipo'", team)
+ if got := read(); len(got) != 0 {
+ t.Fatalf("pending or disabled Equipo visible: %+v", got)
+ }
+ exec("UPDATE team_instances SET state='live' WHERE team_id=? AND app='equipo'", canonical)
+ check(read(), "AAA111", "oficina", "Oficina", "https://equipo.oficina.works", "equipo")
+ exec("DELETE FROM memberships WHERE person_ref=?", chooserPerson)
+ if got := read(); len(got) != 0 {
+ t.Fatalf("removed member still sees Equipo: %+v", got)
+ }
+}
+
+func TestNativeAssertEquipoRegisteredOrigins(t *testing.T) {
+ app := newNativeApp(t)
+ if _, err := migrate.Apply(context.Background(), app.db, (Runtime{role: "credential"}).ServingSchema()); err != nil {
+ t.Fatal(err)
+ }
+ app.runtime.consumers["equipo"] = "https://equipo.oficina.works"
+ app.runtime.registry = newConsumerRegistry(app.runtime.consumers)
+ for _, row := range [][3]string{{"blue-equipo", "https://blue.equipo.oficina.works", "active"}, {"gone-equipo", "https://gone.equipo.oficina.works", "retired"}} {
+ if _, err := app.db.Writer().Exec("INSERT INTO consumers VALUES(?,?,'equipo',?,'2026-11-20',?)", row[0], row[1], row[2], fixtureToken(1)); err != nil {
+ t.Fatal(err)
+ }
+ }
+ if err := app.runtime.registry.load(context.Background(), app.db.Writer(), Origin, app.runtime.keys); err != nil {
+ t.Fatal(err)
+ }
+ d := newDevice(t)
+ grant, _ := d.signInByCode(t, app, "equipo@example.invalid")
+ _, challenge := verifierFor(91)
+ for _, origin := range []string{"https://equipo.oficina.works", "https://blue.equipo.oficina.works"} {
+ w := d.assert(t, app, grant, origin, challenge)
+ if w.Code != 200 {
+ t.Fatalf("registered Equipo: %d %s", w.Code, w.Body.String())
+ }
+ claims := verifyAssertion(t, app, decodeReply(t, w)["assertion"].(string), origin)
+ if claims.Audience != origin || claims.Nonce != mustNativeNonce(t, challenge) || claims.ExpiresAt-claims.IssuedAt != 120 {
+ t.Fatalf("Equipo claims: %+v", claims)
+ }
+ }
+ for _, origin := range []string{"https://equipo.oficina.works/", "https://EQUIPO.oficina.works", "https://equipo.oficina.works:443", "https://equipo.oficina.works.evil.invalid", "https://green.equipo.oficina.works", "https://gone.equipo.oficina.works"} {
+ w := d.assert(t, app, grant, origin, challenge)
+ if w.Code != 400 || decodeReply(t, w)["error"] != "audience" {
+ t.Fatalf("unregistered Equipo admitted: %s %d", origin, w.Code)
+ }
+ }
+}