mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 16:27:33 -10:00
devvm _proxy takes one flag, -config, and running the proxy is Main's only
mode. What only the host does runs in devvm itself, through typed functions:
- internal/agentlogin (new; imports only fetch, jsonc, proxy and state):
File{Kind, Path, Salt, TokenURL} with VMCopy (the VM's copy and what it
keeps as it is), Bindings, Get (refreshing OAuth tokens), plus Hosts,
MCPSecrets and Redact. The salt is a parameter, not a global or
DEVVM_LOGIN_SALT. Login files are read with proxy.ReadRegular (no FIFO
hang, 64 MiB cap) and written with state.WriteFile; the refresh goes
through fetch.NewClient (HTTPS-only redirects, 30 s, reply capped at
1 MiB) with context.WithoutCancel.
- trust.InitCA makes devvm's CA (state.WriteFileMode), replacing -init-ca;
netpolicy's InitCA field is it, and proxy_ca_failed carries the error.
- internal/jsonc: devcontainer's JSONC stripper, now redaction's too; the
redactor's own copy changed commas inside strings.
- proxy.HostOK is exported for agentlogin's MCP host check.
- secrets.Store loses its Login seam and LoginKept; IO loses Stdin and Kept.
Tests: proxy.txtar's login, redact and init-ca cases become unit tests in
agentlogin and trust; proxy.txtar and TestMainRefuses check the old flags
are refused. New: TestRefreshOutlivesItsCaller, TestRefreshFails,
TestGetRefuses, TestLoginFileNotRegular, TestHosts, TestRedactRefuses,
TestRedactJSONKeepsStrings, TestInitCA, TestInitCAFails, TestBundle.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
49 lines
1.8 KiB
Plaintext
49 lines
1.8 KiB
Plaintext
# devvm _proxy: the network policy proxy, hidden. --help lists its one
|
|
# flag, -config.
|
|
exec devvm _proxy --help
|
|
stdout '-config'
|
|
! stdout '-auth-file'
|
|
! stdout '-init-ca|-login|-redact'
|
|
! stderr .
|
|
exec devvm --help
|
|
! stdout _proxy
|
|
|
|
# The proxy runs only with its config (proxy.Config), which holds the VM's
|
|
# password: none, one others may read, one without a password, and one of
|
|
# another version are refused.
|
|
! exec devvm _proxy
|
|
stderr '^devvm: proxy_failed reason=-config is required$'
|
|
! exec devvm _proxy -listen 127.0.0.1:0
|
|
stderr '^devvm: proxy_failed reason=flag provided but not defined: -listen$'
|
|
chmod 0600 nopw.json
|
|
chmod 0600 v2.json
|
|
chmod 0644 open.json
|
|
! exec devvm _proxy --config open.json
|
|
stderr '^devvm: proxy_failed reason=open.json: another user may read or change it$'
|
|
! exec devvm _proxy --config nopw.json
|
|
stderr '^devvm: proxy_failed reason=nopw.json: no password$'
|
|
! exec devvm _proxy -config v2.json
|
|
stderr '^devvm: proxy_failed reason=v2.json: version 2, not 1$'
|
|
! exec devvm _proxy -nope
|
|
stderr '^devvm: proxy_failed reason=flag provided but not defined: -nope$'
|
|
|
|
# What only the host does (devvm's CA, agents' logins, redaction) runs in
|
|
# devvm itself: none of it is reachable from the proxy's arguments.
|
|
! exec devvm _proxy -init-ca ca
|
|
stderr '^devvm: proxy_failed reason=flag provided but not defined: -init-ca$'
|
|
! exists ca
|
|
! exec devvm _proxy -login codex -login-file auth.json -login-vm
|
|
stderr '^devvm: proxy_failed reason=flag provided but not defined: -login$'
|
|
! stdout .
|
|
! exec devvm _proxy -redact json
|
|
stderr '^devvm: proxy_failed reason=flag provided but not defined: -redact$'
|
|
|
|
-- open.json --
|
|
{"version": 1, "listen": "127.0.0.1:0", "password": "k3y"}
|
|
-- nopw.json --
|
|
{"version": 1, "listen": "127.0.0.1:0"}
|
|
-- v2.json --
|
|
{"version": 2, "listen": "127.0.0.1:0", "password": "k3y"}
|
|
-- auth.json --
|
|
{"OPENAI_API_KEY": "sk-real"}
|