Skip to content

[quality] test: BATS coverage for shared.just (powerwash, toggle-tpm2) - #1034

Open
kubestellar-hive[bot] wants to merge 1 commit into
mainfrom
quality/test-shared-just
Open

[quality] test: BATS coverage for shared.just (powerwash, toggle-tpm2)#1034
kubestellar-hive[bot] wants to merge 1 commit into
mainfrom
quality/test-shared-just

Conversation

@kubestellar-hive

Copy link
Copy Markdown
Contributor

Test Improvement

Adds tests/test_shared_just.bats — 14 BATS cases covering
system_files/shared/usr/share/ublue-os/just/shared.just, which had zero
test coverage.

Why this file

powerwash is the most destructive recipe in the repo: it ends in
sudo bootc install reset --experimental, an irreversible factory reset. It is
guarded by two gum choose confirmations plus a bctl powerwash fast path.
None of that gating was verified by any test.

How

The powerwash body is a #!/usr/bin/bash shebang recipe with no just
interpolation, so the test extracts it verbatim and executes it against
stubbed bctl/gum/sudo binaries. This exercises real control flow rather
than grepping recipe text, and requires no just binary in CI.

Asserted behavior:

  • bctl present → delegates to bctl powerwash, and gum/sudo are never invoked
  • declining the first confirmation → cancels, only one prompt, no sudo
  • declining the second confirmation → cancels, no sudo
  • non-affirmative (maybe) and empty answers → treated as declines
  • two prompts are always required; a single "yes" never wipes
  • both confirmations → sudo bootc install reset --experimental, exactly once
  • both prompts carry their warning text
  • toggle-tpm2 uses the absolute /usr/bin/luks-tpm2-autounlock path

All 14 pass locally (bats 1.14.0). Mutation-checked: deleting the second
confirmation from shared.just fails 3 of the tests.

Scope / disjointness

Claimed ground: tests/test_shared_just.bats only — one new test file, no
production code touched.

Deliberately does not touch .github/workflows/unit-tests.yml (claimed by
open PRs #942 and #961) and does not touch system.just (#942),
apps.just (#1007), default.just (#1003), bonedigger-report (#1010),
hooks.py (#1011), or ublue-fastfetch (#1005). CI registration of this and
the other test files not yet wired into unit-tests.yml is tracked separately
by #968.


Filed by quality agent (hold-gated mode). Human review required. Do not merge on my behalf.

— hive: agent=quality backend=copilot model=claude-opus-5

system_files/shared/usr/share/ublue-os/just/shared.just had zero test
coverage. Its powerwash recipe performs an irreversible factory reset
(sudo bootc install reset --experimental) behind two gum confirmations,
with a bctl fast path that must bypass those prompts.

tests/test_shared_just.bats extracts the powerwash shebang recipe body
and executes it against stubbed bctl/gum/sudo binaries, asserting:
bctl delegation short-circuits gum and sudo; declining either
confirmation cancels without wiping; non-affirmative and empty answers
decline; two prompts are always required; and the reset runs exactly
once only after both confirmations. toggle-tpm2 is checked for its
absolute luks-tpm2-autounlock path.

Co-authored-by: Copilot <[email protected]>
Signed-off-by: kubestellar-hive[bot] <kubestellar-hive[bot]@users.noreply.github.com>

@hanthor hanthor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New tests/test_shared_just.bats for the destructive powerwash recipe and toggle-tpm2; extracts and executes the real recipe body against stubbed bctl/gum/sudo, verifying both confirmations are required, non-affirmative/empty answers decline, and the reset command fires exactly once. CI test green; validate fails only on title-lint.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hold Work is intentionally paused. quality testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant