honcho/honcho-cli/tests
Aakash Kattelu 055d73b580
feat(cli): add device code oauth login for honcho servers (#891)
* feat(cli): add device code oauth login for honcho servers

* fix(cli): harden device-auth input validation and transport errors

Reject zero/negative auth-method choices instead of letting Python
negative indexing wrap to the tail of the options list, and wrap httpx
transport failures in the OAuth POST helpers as OAuthFlowError so
connection errors surface through existing caller handling rather than
escaping as an uncaught traceback.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* feat: add HONCHO_CONFIG_DIR env var for cli

* refactor(cli): address review nits on device-auth PR

- split `init` into manual-key and interactive helpers
- document that access_valid checks persisted expiry, not the token
- rename single-letter local in redacted()
- cover 500 alongside 404 in supports_device_login metadata probe
- add config edge-case tests: stale apiKey drop, garbage/string
  accessExpiresAt, empty-env-var popping, refresh-rotation fallback,
  missing-token access_valid

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix(cli): stop deleting shared apiKey on device login; bind oauth grant to its host

apiKey is shared with sibling tools that read it from the same config
file, so device login must not remove it. Precedence flips to a live
OAuth token over apiKey; a dead grant now degrades to the saved key
with a warning instead of aborting. The oauth block records the host
it was minted against and is ignored (no use, no refresh) when
base_url points elsewhere, so a staging grant is never sent to prod.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-17 13:16:55 -07:00
..
__init__.py feat: adding honcho-cli package (#424) 2026-04-20 13:27:35 -04:00
conftest.py feat(cli): add device code oauth login for honcho servers (#891) 2026-07-17 13:16:55 -07:00
test_commands.py feat: adding honcho-cli package (#424) 2026-04-20 13:27:35 -04:00
test_common.py feat(cli): add device code oauth login for honcho servers (#891) 2026-07-17 13:16:55 -07:00
test_config.py feat(cli): add device code oauth login for honcho servers (#891) 2026-07-17 13:16:55 -07:00
test_oauth.py feat(cli): add device code oauth login for honcho servers (#891) 2026-07-17 13:16:55 -07:00
test_validation.py feat: adding honcho-cli package (#424) 2026-04-20 13:27:35 -04:00