[quality] test: BATS coverage for files/bin/system-container (start/stop/enter/reset dispatch) - #38
Merged
Merged
Conversation
Adds tests/unit/system-container_test.bats: 25 cases covering the root privilege gate (sudo re-exec), the start/stop/enter/reset dispatch table, missing-name usage errors, machinectl exit-code propagation, and the unknown-subcommand fallthrough. machinectl, sudo and id are stubbed on PATH so nothing escalates or touches a real machine. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: sec-check[bot] <sec-check[bot]@users.noreply.github.com>
This was referenced Aug 29, 2026
hanthor
approved these changes
Sep 2, 2026
hanthor
left a comment
Member
There was a problem hiding this comment.
Fetched the real files/bin/system-container script and confirmed all 25 BATS cases (dispatch, usage messages, exit codes, privilege gate) match actual behavior exactly. CI green.
Generated by Claude Code
This was referenced Sep 4, 2026
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.
Claimed ground: projectbluefin/server, one new file
tests/unit/system-container_test.bats. Script under test:files/bin/system-container— the root privilege gate and thestart/stop/enter/resetcase dispatch. Tracker cluster: quality/test-coverage for the server repo.Disjointness: no other open
serverPR touchesfiles/bin/system-containerortests/unit/system-container_test.bats. #30 addstests/unit/conftest.py+tests/unit/test_docs_checks.pyand aJustfile test-unitrecipe — different files; this PR touches noJustfileand no Python. #37 changesfiles/os/justfile, #36 the sysupdate keyring, #29 the sshd drop-in, #34project.conf/Justfile/.github/scripts/check-release-version.py, #22/#25/#26/#27 the installer.bstelements and docs — all disjoint.Why
files/bin/system-containeris the user-facing entry point for machine management on Bluefin Server. It re-execs itself undersudo, then hands arguments straight tomachinectl. Every branch runs as root, and three of the four subcommands are destructive or disruptive (poweroff,remove). It had zero test coverage, so a typo in the case table (for examplemachinectl stopinstead ofmachinectl poweroff, or a dropped[ -n "$name" ]guard) would ship silently.What
tests/unit/system-container_test.bats— 25 cases.id,sudoandmachinectlare replaced with logging stubs prepended toPATH, so no privilege escalation and no container operation ever happens; each test asserts on the recorded argv.sudo "$0" "$@"and does not reachmachinectl; the re-exec still fires for a bare no-argument invocation; root invocation never callssudo.start→machinectl start,stop→machinectl poweroff(explicitly asserted as notmachinectl stop),enter→machinectl shell,reset→machinectl remove.usage: system-container <cmd> <name>message and invokes nothing.machinectlfailures (7, 3, 5) surface unchanged rather than being swallowed by thecaseblock.helpdefault, an unknown subcommand, and a wrong-caseSTARTall exit 1 with the four-way usage banner and touch nothing.--is taken as the machine name (the script does no option parsing).set -euo pipefail.Verification
Related
Refs #33 — no CI workflow runs
tests/unityet. This PR deliberately adds no workflow file (the bot token lacks theworkflowspermission) and noJustfilerecipe (to stay textually disjoint from #30 and #34). Run locally with the command above.Tests only — no production code, no workflow, no docs changed.
Filed by quality agent (hold-gated mode) — do not merge, do not remove the
holdlabel.— hive: agent=quality backend=copilot model=claude-opus-5