Repository navigation
Conversation
The connect setup, guided setup, operator, start-wait and profile layer tests ran against connectSetupServer, a mock that answered most reads to any bearer and modeled each scenario as a field. They now run against internal/connector/fakebasecamp, and connectSetupServer is deleted. Each old knob is now a fact of the world or a fault: project membership decides what the agent lists and reads, a boss on the agent's profile, people readable only by some, a client secret rotated by a connection on another computer, a token repointed at another agent, and injected faults for refused project reads, a failed mint, a profile with no id and a rate-limited token endpoint. The fake gains Tickets(), every stream ticket it issued, so the tests that a command never echoes a ticket check the tickets actually handed out.
There was a problem hiding this comment.
Copilot review overview
🟢 Approved
The migration preserves the tested scenarios while improving realism, consistency, and credential-leak coverage.
Review effort: Balanced
Findings: None
What changed in this PR
Migrates connect setup tests to the shared fake Basecamp without changing CLI behavior.
Changes:
- Replaces the bespoke setup server with realistic world state and faults.
- Adds thread-safe tracking of issued stream tickets.
- Strengthens credential and ticket leak assertions.
[!TIP]
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or rungh pr ready --undo.
Click "Ready for review" or rungh pr readyto reengage.
| File | Description |
|---|---|
internal/connector/fakebasecamp/tickets_test.go |
Tests issued-ticket tracking. |
internal/connector/fakebasecamp/cable.go |
Exposes sorted ticket snapshots. |
internal/commands/profile_layers_test.go |
Uses the shared fake server. |
internal/commands/connect_start_wait_test.go |
Models token rate limits through fake faults. |
internal/commands/connect_setup_test.go |
Replaces the legacy setup mock and strengthens assertions. |
internal/commands/connect_setup_guided_test.go |
Models guided scenarios using fake world state. |
internal/commands/connect_operator_test.go |
Updates the operator fixture to use the fake server. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
4619ba7 to
01f042c
Compare
|
🤖 Two things before this can land:
Copilot's approval is on |
|
Closing: we are retaining the existing setup tests rather than rewriting them around the fake Basecamp from the retired testing stack. |
PR 1 of a stack of 8 that tests
basecamp connectend to end. It is stacked on #822 (the fake Basecamp) and changes no behaviour of the CLI.Why
The connect setup tests ran against
connectSetupServer, a mock that answered most reads to any bearer and modeled each scenario as a field (refuseAgentReads,agentAsUser,boss,agentProjects,refuseSecret,rateLimitMints, ...). It drifted from Basecamp in small ways: project reads ignored membership, the project list was a separate field from what the agent could read, and the client secret never rotated. One fake for every connect test means a scenario is set up the way Basecamp would be, and the later e2e PRs run against the same one.What
connect_setup_test.go,connect_setup_guided_test.go,connect_operator_test.go,connect_start_wait_test.goandprofile_layers_test.gonow run againstinternal/connector/fakebasecamp.connectSetupServeris deleted.Each old knob is now a fact of the world or a fault:
agentProjects-> the agent's project membership (agentOnProjects). The list and the reads agree now.boss->BossIDon the agent (ownedByTheOperator).refusePeopleand the "Colleague" ->ReadableByon the person (readableOnlyBy).agentAsUser->Agent: false;grantScope->Connection.Scope.agentID = 777andagentID++-> the client and its tokens repointed at another Agent (repointAgent).refuseSecret-> the secret rotated by a connection on another computer (connectedElsewhere). The fake then refuses it withinvalid_client, and the reconnect rotates in a secret it accepts. No fault and no toggle are needed.refuseAgentReads-> 403 on project and project people reads, for Agents only.mintFailure-> a 422 fault on the stream ticket;agentID = 0-> a 200 fault with a profile that has no id.duringMint->Before(RouteStreamTicket, ...);rateLimitMints->TokenRateLimited(3600);mintsandintakeCount->Count(...).One addition to the fake:
Server.Tickets()returns every stream ticket it issued. The tests check that a command never prints a ticket, so they need the real ticket values, and tickets are not part of theWorld. It has its own test infakebasecamp.Assertions. Every assertion is kept. Some are stronger now:
TestGuidedConnectSetupLeavesARefusedCredentialThePersonKeepsnow also checks that the refusal was explained and that the reconnect question was asked. Before, it passed even with a credential that was not refused.assert, notrequire.Tests
bin/cigreen.go test -race -count=10(1100 runs, no failures, no races).ReadableByhas no effect, the tests that depend on them fail.Summary by cubic
Migrates the
connect setuptests from the customconnectSetupServermock to the shared fake Basecamp, with no CLI behavior changes.Refactor
Tickets(), listing every stream ticket it issued, so no-echo assertions compare against real tickets.Written for commit 01f042c. Summary will update on new commits.