Repository navigation
test: contract tests for how callers use nodkey run - #209
Merged
Merged
Conversation
Fixes #198 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Fixes #198
The masking change of #171 passed every test, but it broke two kinds of callers (#191). These tests pin what a caller of
nodkey runsees today (0.7.0), as DESIGN.md section 5 ("What the command gets") and docs/setup.md section 11 ("Keep the mask on") describe it.test/contract/: black-box tests against the builtnodkeybinary and a trial broker (nodkey try). The tests answer its requests on its stdin: approve fordemo-token, deny for all else.***through a pipe; the documented way (the program runs insidenodkey runand reads its own environment) gets the value. Values are compared as SHA-256 only; no test prints a value.nodkey(its/proc/PID/statreadable, its/proc/PID/exenot), whose parent is the caller; with execve, the command has nodkey's PID and the caller as parent.Also a deny: exit 77, and the command never runs.
test/contract/README.md: a change to a test here is a change in behavior for callers.The tests have no build tag and run in the
go test -race ./...job of every PR (about 5 s on a laptop). They pass on main: no difference between the docs and the code turned up.This PR only adds new test files under
test/contract/and its README, so the new gate (#197) does not count it as a change in behavior.Behavior for callers
Changes behavior for existing callers: no
Tests
go vet ./...,go test -race ./...,go test -race -count=3 ./test/contract/...,golangci-lint run --build-tags e2e,gofmt -l .: all pass..claude/agents/security-reviewer.md, two runs) and a correctness review: no critical, high or medium security finding. Fixed: a masked SIGINT check could pass by chance (Linux delivers SIGHUP before SIGINT; now the test waits 500 ms before the last signal), the deny failure no longer prints stderr, the trial's stdin closes on stop, an ignored signal (as undernohup) is a failure in CI and a skip elsewhere in both signal tests, and the README says that any change to a file here (also the harness) counts.TestDeniedis for the whole run, so only the first subtest proves that the deny came from a tap; the later ones rely on the deny cache, as the comment says. The exit 77 and "the command never ran" are checked in every subtest.Progress
test/contract/README.mdtest (stable)failed ininternal/brokerTestLoginRememberedTimer("value 2 that the store gave out is not cleared"); this PR does not touch that code, the contract tests passed in that run, and the rerun passed. 20 local runs of that test pass. It is a rare flake.🤖 Generated with Claude Code