Repository navigation
Make unit tests pass as root and without a container runtime - #6875
Merged
Merged
Conversation
Running the unit suite as root in a container with no container runtime or keyring (as Anthropic's OSS Scanner does) failed six packages for environmental reasons rather than code defects. - Tests that force a write failure with chmod now skip as root, which bypasses permissions, via a new shared osperm.SkipIfRoot helper. - pkg/api server tests inject mock runtime and client managers, so Build() no longer needs a container runtime on the host. - The real-keyring test skips when no keyring provider is available instead of sniffing CI environment variables. - The LLM partial-failure test breaks apply with malformed settings JSON instead of a read-only directory, so it runs as root and on Windows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rdimitrov
requested review from
ChrisJBurns,
JAORMX,
amirejaz,
aponcedeleonch,
jhrozek,
reyortiz3 and
tgrunnagle
as code owners
October 20, 2026 07:34
rdimitrov
added a commit
that referenced
this pull request
Oct 20, 2026
The environment-dependent unit tests now skip or use mocks (#6875), so the suite passes in the scanner image and the expected-failure list is no longer accurate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 of 7 tasks
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6875 +/- ##
==========================================
- Coverage 79.77% 79.65% -0.13%
==========================================
Files 820 821 +1
Lines 83723 83726 +3
==========================================
- Hits 66791 66691 -100
- Misses 16927 17030 +103
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
rdimitrov
added a commit
that referenced
this pull request
Oct 20, 2026
* Add OSS Scanner audit configuration Register ToolHive with Anthropic's OSS Scanner. The Dockerfile gives the scanner a reproducible build that runs the unit tests, and the threat model tells it which inputs are untrusted and which failures count as vulnerabilities. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com> * Drop expected test failures from scanner docs The environment-dependent unit tests now skip or use mocks (#6875), so the suite passes in the scanner image and the expected-failure list is no longer accurate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com> 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.
Summary
Running the unit suite as root, in a container with no container runtime and no keyring (the setup used by Anthropic's OSS Scanner, and by anyone running tests in a dev container), fails six packages. None of these failures is a code defect: each test assumes something about its environment. This PR makes those tests skip with a clear reason, or removes the assumption, without weakening what they assert when the precondition holds.
osperm.SkipIfRoot(t)helper (test/testkit/osperm) skips them as root. It is used inpkg/client,pkg/plugins/pluginsvc,pkg/skills/skillsvc, and replaces the existing inline check inpkg/secrets.pkg/apiserver tests:Build()created a real container runtime and client manager (which creates its own runtime), so the tests failed withno available runtime found. AnewTestServerBuilderhelper now injects gomock runtime, client, skill and plugin managers, so these tests run everywhere instead of being skipped.TestCompositeProvider_RealProvidersskips when no keyring provider is available, instead of sniffing CI environment variables.TestRunLLMSetup_PartialFailure: made claude-code's apply fail via a read-only.claudedirectory, which root writes through. It now uses a malformedsettings.json, which fails for any user on any OS, so the Windows skip is gone too. Detection in this test never consults$PATH(the test entries set no binary name), so it does not depend on what is installed on the host.Type of change
Test plan
task test)task test-e2e)task lint-fix)task testpasses locally on macOS. Lint was run with the CI-pinned golangci-lint v2.15.0 on the touched packages (0 issues). The full unit suite was run in the OSS Scanner image (golang:1.27, as root) withdocker run --rm --network none --cpus 2 --memory 8g; every package passes, and the tests above reportSKIPwith their reason where the precondition is missing.Special notes for reviewers
Other chmod-based tests exist in the repo but already pass as root, so they were left unchanged.
🤖 Generated with Claude Code