Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
| 1 | # CLI `composio whoami` Test |
| 2 | |
| 3 | Verifies that `composio whoami` prints the account of the user API key as JSON, respects stdout piping, and fails with how to recover when the backend rejects the key. |
| 4 | |
| 5 | ## Why This Exists |
| 6 | |
| 7 | The CLI separates decoration (stderr) from data (stdout), and a rejected key must fail rather than print an empty account. This suite runs the CLI against a mock Composio API (`ts/packages/cli/scripts/mock-whoami-server.ts`), so it needs no secret and no live backend. |
| 8 | |
| 9 | The mock answers `GET /api/v3.1/auth/session/info` and `GET /api/v3.1/org/consumer/config` for one accepted key, and answers every request with any other key with the backend's 401 for a revoked user API key (`UserApiKey_Unauthorized`). |
| 10 | |
| 11 | ## What It Tests |
| 12 | |
| 13 | | Test | Description | |
| 14 | | -------------- | ----------------------------------------------------------------------------------------------------------------------------- | |
| 15 | | Accepted key | `composio whoami` exits 0, stdout is the account JSON with the mock's email and org, stderr is empty | |
| 16 | | File redirect | `composio whoami > out.txt` leaves stdout and stderr empty, and `out.txt` holds the account JSON | |
| 17 | | Rejected key | `composio whoami` exits 1, stdout is empty, stderr names the rejection and says to replace the key in `COMPOSIO_USER_API_KEY` | |
| 18 | | Mock API usage | The CLI read the session info with each key | |
| 19 | |
| 20 | ## Requirements |
| 21 | |
| 22 | None. Each command sets `COMPOSIO_BASE_URL`, `COMPOSIO_USER_API_KEY` and `COMPOSIO_CACHE_DIR` itself. |
| 23 | |
| 24 | ## Isolation Tool |
| 25 | |
| 26 | **Docker** with the CLI built from the current monorepo source. The container reaches the mock on the host through `host.docker.internal`. |
| 27 | |
| 28 | ## Running |
| 29 | |
| 30 | ```bash |
| 31 | pnpm test:e2e:cli |
| 32 | ``` |