# devvm secret: the secrets kept on this machine, listed bare. The # Keychain is the stub's on macOS (service DEVVM_SECRET_SERVICE), a file # elsewhere. Every value here is fake. exec devvm --help stdout '^ secret ' ! stdout '^ auth ' ! stdout ' get ' ! exec devvm auth claude stderr '^devvm: no_command word=auth$' # No command prints a secret's value: VMs' proxies look values up in # their own process. ! exec devvm secret get github stderr '^devvm: no_subcommand command=devvm secret commands=rm, set, unuse, use given=get$' # A value saved where devvm keeps it is saved; the Keychain is asked # for it by name, the value in no process's arguments. exec devvm secret stdout '^github +no +GH_TOKEN +Authorization +api\.github\.com, github\.com, codeload\.github\.com, raw\.githubusercontent\.com +- +- +-$' stdout '^proxy +no +- +- +- +- +- +-$' [darwin] stdin github0.token [darwin] exec stub keychain-set github [!darwin] mkdir $DATA/secrets [!darwin] cp github0.token $DATA/secrets/github stub_reset exec devvm secret stdout '^github +yes .* -$' stdout '^claude +no +CLAUDE_CODE_OAUTH_TOKEN +Authorization +api\.anthropic\.com +- +- +-$' [darwin] stub_calls [darwin] stdout '^security find-generic-password -s devvm-test -a github -w$' # A claude token in devvm's environment wins. env CLAUDE_CODE_OAUTH_TOKEN=sk-ant-oat01-testfake exec devvm secret stdout '^NAME +SAVED +VARIABLE +HEADER +HOSTS +PATH +METHODS +USED BY$' stdout '^claude +yes .* -$' # --json: saved or not, its hosts, header and variable, never the token. exec devvm secret --json stdout '\A{\n "version": 1,\n "secrets": \[\n {\n "name": "claude",\n "saved": true,\n "used_by": \[\],\n "custom": false,\n "hosts": \[\n "api\.anthropic\.com"\n \],\n "header": "Authorization",\n "env": "CLAUDE_CODE_OAUTH_TOKEN",\n "prefix": "sk-ant-oat01-"\n },\n' stdout '\n "name": "proxy",\n "saved": false,\n "used_by": \[\],\n "custom": false,\n "hosts": \[\]\n }\n' ! stdout testfake env CLAUDE_CODE_OAUTH_TOKEN= # Only devvm's own names and names of yours: never a path. A name of yours # that isn't saved is no secret. ! exec devvm secret set ../../etc/passwd --stdin stderr '^devvm: bad_secret_name given=\.\./\.\./etc/passwd most=40$' stderr '^usage_help command=devvm secret set$' ! exec devvm secret rm ../x stderr '^devvm: no_secret secret=\.\./x$' stderr '^usage_help command=devvm secret rm$' ! exec devvm secret rm --force nope stderr '^devvm: no_secret secret=nope$' # --no-input never asks, and never reads an answer: the question fails, # naming the flag that answers it. Nothing is saved: github keeps the token # saved above. stdin github.token ! exec devvm --no-input secret set github stderr '^token_prompt$' stderr '^devvm: no_input answer=--stdin$' [darwin] exec stub keychain github [darwin] stdout '\Aghp_testfake\n\z' [!darwin] grep '^ghp_testfake$' $DATA/secrets/github [darwin] env DEVVM_SECRET_SERVICE='x -a y' [darwin] stdin claude.token [darwin] ! exec devvm secret set claude --stdin [darwin] stderr '^devvm: bad_secret_service$' env DEVVM_SECRET_SERVICE=devvm-test # set and rm; ls lists every secret, whether saved, and its VMs. A value # goes in through stdin, never in a process's arguments. stub_reset stdin github.token exec devvm secret set github --stdin [darwin] stdout '^==> secret_saved_keychain secret=github$' [!darwin] stdout '^==> secret_saved file=\S*/data/devvm/secrets/github secret=github$' [darwin] exec stub keychain github [darwin] stdout '\Aghp_testfake2\n\z' [!darwin] grep '^ghp_testfake2$' $DATA/secrets/github stub_calls ! stdout ghp_testfake2 [darwin] stdout '^security -i$' [!darwin] exec sh -c 'stat -c %a "$DATA/secrets" "$DATA/secrets/github"' [!darwin] stdout '^700\n600\n$' exec devvm secret stdout '^claude +no .* -$' stdout '^github +yes .* -$' ! exec devvm secret rm github stderr '^secret_rm_confirm name=github\ndevvm: no_input answer=--force$' exec devvm secret rm --force github stdout '^==> secret_removed secret=github$' [darwin] ! exec stub keychain github [!darwin] ! exists $DATA/secrets/github ! exec devvm secret rm --force github stderr '^devvm: no_secret secret=github$' # Tokens that are refused: nothing saved. stdin empty.token ! exec devvm secret set github --stdin stderr '^devvm: no_token$' stdin quotes.token ! exec devvm secret set github --stdin stderr '^devvm: token_quotes$' stdin browser.token ! exec devvm secret set claude --stdin stderr '^devvm: not_setup_token$' stdin placeholder.token ! exec devvm secret set github --stdin stderr '^devvm: token_is_placeholder$' exec devvm secret stdout '^claude +no .* -$' stdout '^github +no .* -$' # devvm secret set claude without a terminal or --stdin is refused, # naming --stdin, and reads nothing. stdin claude.token ! exec devvm secret set claude stderr '^token_prompt\ndevvm: no_input answer=--stdin$' exec devvm secret stdout '^claude +no .* -$' # With piped answers, the CLI tests' way to answer, its question reads # a line instead, and shows nothing. env DEVVM_PIPED_ANSWERS=1 stdin claude.token exec devvm secret set claude env DEVVM_PIPED_ANSWERS= [darwin] stdout '^==> secret_saved_keychain secret=claude$' ! stderr . [darwin] exec stub keychain claude [darwin] stdout '\Ask-ant-oat01-testfake\n\z' [!darwin] grep '^sk-ant-oat01-testfake$' $DATA/secrets/claude ! exec devvm secret set codex stderr '^devvm: secret_name_taken given=codex$' ! exec devvm secret ls stderr '^devvm: no_subcommand command=devvm secret commands=rm, set, unuse, use given=ls$' # use and unuse bind a token to the folder's VM, an open one's too: its # proxy has the VM's bindings, as every tier's does. project off ! exec devvm secret use github stderr '^devvm: no_vm dir=\S*/off$' exec devvm --network open --no-git-protect exec devvm secret use github stdout '^==> secret_used secret=github vm=devvm-off-[0-9a-f]{14}$' stderr '^devvm: no_github_token vm=devvm-off-[0-9a-f]{14}$' vm_name OFF off vm_state $OFF_dir/vm.json stdout '^secrets.names=github$' exec cat $OFF_dir/run/secrets.json stdout '^\{"version":1,"bindings":\[\]\}$' exec devvm secret stdout '^github +no .* devvm-off-[0-9a-f]{14}$' exec devvm secret --json stdout '^ "name": "github",\n "saved": false,\n "used_by": \[\n "devvm-off-[0-9a-f]{14}"\n \],\n' exec devvm secret unuse github stdout '^==> secret_unused secret=github vm=devvm-off-[0-9a-f]{14}$' ! stderr . vm_state $OFF_dir/vm.json ! stdout '^secrets.names=.' ! exec devvm secret unuse nope stderr '^devvm: no_secret secret=nope$' ! exec devvm secret unuse NOPE stderr '^devvm: no_secret secret=NOPE$' ! exec devvm secret use codex-key stderr '^devvm: no_secret secret=codex-key$' # The company proxy's password: saved as the others are, on stdin, and # never a VM's. stdin $WORK/proxy.password exec devvm secret set proxy --stdin [darwin] stdout '^==> secret_saved_keychain secret=proxy$' [darwin] exec stub keychain proxy [darwin] stdout '\Apa55 word\n\z' [!darwin] grep '^pa55 word$' $DATA/secrets/proxy exec devvm secret stdout '^proxy +yes +- +- +- +- +- +-$' ! exec devvm secret use proxy stderr '^devvm: secret_host_only secret=proxy$' vm_state $OFF_dir/vm.json ! stdout '^secrets.names=.' # Without --stdin and no terminal, it asks for a password. stdin $WORK/proxy.password ! exec devvm --no-input secret set proxy stderr '^password_prompt$' stderr '^devvm: no_input answer=--stdin$' exec devvm secret rm --force proxy stdout '^==> secret_removed secret=proxy$' # With network policy the VM's proxy gets the binding at once, and a # token saved or removed later too; never the value. project net exec devvm --network allowlist --no-git-protect vm_name NET net exec cat $NET_dir/run/secrets.json stdout '^\{"version":1,"bindings":\[\]\}$' exec devvm secret use github stderr '^devvm: no_github_token ' exec cat $NET_dir/run/secrets.json stdout '^\{"version":1,"bindings":\[\]\}$' stdin $WORK/github.token exec devvm secret set github --stdin exec cat $NET_dir/run/secrets.json stdout '^\{"version":1,"bindings":\[\{"name":"github","kind":"secret","hosts":\["api.github.com","github.com","codeload.github.com","raw.githubusercontent.com"\],"header":"Authorization","placeholder":"devvm-proxy-managed-github-[0-9a-f]{32}"' ! stdout ghp_testfake2 exec cat $NET_dir/run/secrets.policy stdout '^api.github.com:443$' exec devvm secret unuse github exec cat $NET_dir/run/secrets.json stdout '^\{"version":1,"bindings":\[\]\}$' exec devvm secret use github exec devvm secret rm --force github exec cat $NET_dir/run/secrets.json stdout '^\{"version":1,"bindings":\[\]\}$' -- github0.token -- ghp_testfake -- github.token -- ghp_testfake2 -- claude.token -- sk-ant-oat01-testfake -- empty.token -- -- quotes.token -- ghp_x" -A -T " -- browser.token -- some-browser-code -- placeholder.token -- devvm-proxy-managed-github-0123456789abcdef0123456789abcdef -- proxy.password -- pa55 word