Skip to content

[quality] test: cover buildAgentMinter mint-credential bootstrap (src/cmd/hive/main.go) - #5695

Merged
kubestellar-prow[bot] merged 1 commit into
v4from
quality/test-build-agent-minter
Sep 2, 2026
Merged

[quality] test: cover buildAgentMinter mint-credential bootstrap (src/cmd/hive/main.go)#5695
kubestellar-prow[bot] merged 1 commit into
v4from
quality/test-build-agent-minter

Conversation

@kubestellar-hive

Copy link
Copy Markdown
Contributor

Test Improvement

Adds src/cmd/hive/build_agent_minter_test.go covering buildAgentMinter (src/cmd/hive/main.go:890), previously 0% covered despite sitting on the per-agent mint-credential path (0% → 93.3%):

  • fail-closed validation: missing mint.key_path and missing mint.issuer (and that issuer validation fails before any key file is created)
  • corrupt signing key surfaces a loading mint signing key error instead of silently regenerating (which would orphan outstanding tokens)
  • key bootstrap creates the signing key with 0600 perms; mint round-trip issues a token and rejects an empty agent name
  • rebuild against the same path reuses the persisted key
  • MaxTTLSeconds=0 falls back to the package default and still mints

Claimed ground: buildAgentMinter in src/cmd/hive/main.go only — disjoint from open PR #5665 (labelPlanSink / planFromLabeledIssues in src/cmd/hive/plan_from_label_sink_test.go).

Verified: go test -run TestBuildAgentMinter ./cmd/hive/ passes; full ./cmd/hive suite unaffected.


Filed by quality agent (hold-gated mode). Human review required.

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

…md/hive

buildAgentMinter (src/cmd/hive/main.go) was 0% covered despite issuing
per-agent mint credentials. Adds hermetic tests for: key_path/issuer
fail-closed validation, corrupt-key load failure, key bootstrap with
0600 perms, mint round-trip incl. empty-agent-name rejection, key reuse
across rebuilds, and zero-TTL default fallback.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: sec-check <sec-check@hive.kubestellar.io>
@kubestellar-hive kubestellar-hive Bot added the hold label Sep 2, 2026
@kubestellar-prow kubestellar-prow Bot added dco-signoff: yes Indicates the PR's author has signed the DCO. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 2, 2026
@kubestellar-hive kubestellar-hive Bot added quality testing agent/quality Approved by a Hive merger/owner for auto-merge on green CI hive/hosted-available-oke-11-placeholder-r05x Approved by a Hive merger/owner for auto-merge on green CI labels Sep 2, 2026
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Changelog: this PR changes code but carries no changelog entry
(no changelog.d/ fragment and no CHANGELOG.md edit).

If it is user-visible — a feature, a fix an operator would notice, a
security change, a migration, a deprecation, or anything breaking —
please add a fragment file changelog.d/<category>-<pr-or-slug>.md
containing exactly your entry (see changelog.d/README.md; the
category is one of added/changed/deprecated/fixed/security). Please
do not append to CHANGELOG.md's ## Unreleased directly — that
shared section is the merge-conflict generator fragments replaced
(#5675). If it is a refactor, a test-only change, or dependency
churn, no entry is needed and you can ignore this.

This is a reminder, not a gate; it never blocks a merge.

@clubanderson

Copy link
Copy Markdown
Member

Review — OK to merge on green. Checked the assertions against buildAgentMinter in src/cmd/hive/main.go — error strings and validation order match the production path, and the invariants are real ones, not line-coverage filler:

  • Fail-closed on missing mint.key_path / mint.issuer, with the issuer case additionally proving validation fails before any key file is created (ordering, not just presence).
  • Corrupt key surfaces the loading mint signing key wrap instead of silently regenerating — the invariant that actually protects outstanding tokens, and the reuse test pins the other half (second build against the same path must not rotate the key).
  • 0600 on the bootstrapped key, empty agent name refused, MaxTTLSeconds=0 falls through to the package default.

On the mint-deadlock incident class: these tests call buildAgentMinter directly with temp-dir key paths and take no locks at all — same shape as production (the function itself is lock-free; the deadlock zone was hub-side). No test-only locking that could mask or invert a production lock order. Scope claim holds: one new file, disjoint from #5665.

@clubanderson clubanderson added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Sep 2, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow
kubestellar-prow Bot merged commit 86a68d8 into v4 Sep 2, 2026
61 of 66 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the quality/test-build-agent-minter branch September 2, 2026 16:41
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

Check out what's new:

Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey

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

Labels

agent/quality Approved by a Hive merger/owner for auto-merge on green CI approved Indicates a PR has been approved by an approver from all required OWNERS files. copilot dco-signoff: yes Indicates the PR's author has signed the DCO. hive/hosted-available-oke-11-placeholder-r05x Approved by a Hive merger/owner for auto-merge on green CI hold lgtm Indicates that a PR is ready to be merged. quality size/L Denotes a PR that changes 100-499 lines, ignoring generated files. testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant