Ask a real Mac the questions the proxy rules rest on - #71
Merged
Conversation
Two claims about `networksetup` hold up this package's rules, and Apple documents neither. Whether the server address survives switching the proxy off is what the comment on Satisfies asserts. Whether the bypass list can be read back at all is why Verify stopped comparing it. Both were settled by reading behaviour out of our own source, because there is no Mac here to try them on. CI already runs this package's tests on macos-latest, and a hosted runner is a real Mac that can be asked. So it is asked: set a proxy, switch it off, read it back, and report which way the machine actually behaves. The rule is checked either way round. Satisfies does not read the address when the target is off, so it is correct whichever answer comes back — but the comment explaining it would be wrong, and the next person to touch this would be reasoning from a false premise. The test logs what it found so that premise is on the record rather than in someone's head. The other direction is covered too: a proxy that really is configured has to verify. That path has always worked in the field — users' proxies were being set, which is how the fault behind all of this was reported — so a failure there means the rule drifted away from the machine rather than the machine surprising us. That is the regression #69 fixed, and this is what would have caught it. It reconfigures the machine's own network settings, so it does not run unless asked for by name. Nobody's laptop should have its proxy changed by `go test ./...`, and an ephemeral runner is the only place where being wrong about the restore costs nothing. The restore is registered before the first change and runs whatever the test does. It drives networksetup through sudo rather than through Apply, which asks for the password with osascript and would hang with nobody there to answer.
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.
Closes the biggest piece of unverified reasoning left over from #66 and #69 — without needing a Mac.
The problem
Two claims about
networksetuphold up this package's rules, and Apple documents neither:Satisfiesasserts.Verifystopped comparing it in Verify only what the machine can be asked to report, and act only when it must #69.Both were settled by reading behaviour out of our own source, because there is no Mac here to try them on. That reasoning shipped in v1.0.19.
The idea
CI already runs this package's tests on
macos-latest. A hosted runner is a real Mac, and it has passwordless sudo. So it can simply be asked.The test sets a proxy, switches it off, reads it back, and reports which way the machine actually behaves:
or
Checked either way round
Satisfiesdoes not read the address when the target is off, so it is correct whichever answer comes back. What would be wrong is the comment explaining it — and the next person to touch this would be reasoning from a false premise. The test logs what it found so that premise is on the record rather than in someone's head.The other direction is covered too: a proxy that really is configured has to verify. That path has always worked in the field — users' proxies were being set, which is how the fault behind all of this was reported — so a failure there means the rule drifted away from the machine rather than the machine surprising us. That is exactly the regression #69 fixed, and this is what would have caught it.
Safety
WHITEVPN_SYSPROXY_INTEGRATION=1). Nobody's laptop should have its proxy changed bygo test ./....networksetupthroughsudo, not throughApply, which asks for the password withosascriptand would hang with nobody there to answer.What this does not do
It does not exercise the administrator prompt, the banner, or the app end to end — those still need a human at a Mac. It settles the two mechanical facts underneath them, which is the part that was guessed.
🤖 Generated with Claude Code