test: unset all age env vars in make test target#2208
Merged
felixfontein merged 1 commit intoJun 4, 2026
Conversation
The make test target unset SOPS_AGE_KEY_FILE and SOPS_AGE_KEY_CMD to
isolate the test environment, but the age package also reads
SOPS_AGE_KEY, SOPS_AGE_RECIPIENT, SOPS_AGE_SSH_PRIVATE_KEY_FILE and
SOPS_AGE_SSH_PRIVATE_KEY_CMD. A developer with any of these set in their
shell gets spurious failures in TestMasterKey_loadIdentities, because the
subtests assert an exact unusedLocations count and the SSH variants also
attempt to open or run the inherited key, for example:
open /etc/ssh/ssh_host_ed25519_key: permission denied
Unset the full set of age env vars the target intends to isolate so the
test run is hermetic regardless of the developer's environment.
Fixes #1990
Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
felixfontein
approved these changes
Jun 4, 2026
felixfontein
left a comment
Contributor
There was a problem hiding this comment.
Thanks for fixing this!
Contributor
|
@arpitjain099 thanks for your contribution! |
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 this fixes
make testunsetsSOPS_AGE_KEY_FILEandSOPS_AGE_KEY_CMDto isolate the test environment, but theagekeysource reads four other environment variables that are not unset:SOPS_AGE_KEY,SOPS_AGE_RECIPIENT,SOPS_AGE_SSH_PRIVATE_KEY_FILE, andSOPS_AGE_SSH_PRIVATE_KEY_CMD.When a developer has any of these set in their shell,
TestMasterKey_loadIdentitiesfails spuriously. The subtests assert an exactunusedLocationscount, so any inherited age variable throws the count off, and the SSH variants additionally try to open or run the inherited key. The reported symptom (#1990) is:which happens because a developer's
SOPS_AGE_SSH_PRIVATE_KEY_FILEleaks into the test run.The change
Unset the full set of age environment variables the
testtarget intends to isolate, matching the existingunset ...; unset ...;style already on that line:I went beyond just
SOPS_AGE_SSH_PRIVATE_KEY_FILEbecauseSOPS_AGE_SSH_PRIVATE_KEY_CMDis the symmetric sibling and produces the identical class of failure, andSOPS_AGE_KEY/SOPS_AGE_RECIPIENTbreak the same exact-count assertions if inherited. The six variables here are exactly the ones theagepackage looks up inage/keysource.go. Happy to narrow this to onlySOPS_AGE_SSH_PRIVATE_KEY_FILEif you would prefer the minimal change.How I verified
With
SOPS_AGE_SSH_PRIVATE_KEY_FILEpointing at a non-age file,go test -run TestMasterKey_loadIdentities ./age/reproduces the failure from the issue. Running the same package after the unsets in this PR passes. I also confirmedSOPS_AGE_SSH_PRIVATE_KEY_CMDtriggers the same failure, which is why it is unset here too. CI runs the suite throughmake test, so it picks up this isolation as well.Fixes #1990