Skip to content

[quality] test: pin contributor token-reissue rotation semantics (src/pkg/dashboard/api_contribute.go handleContributeReissueToken) - #6348

Merged
kubestellar-prow[bot] merged 1 commit into
v4from
quality/reissue-token-rotation-tests
Sep 9, 2026
Merged

[quality] test: pin contributor token-reissue rotation semantics (src/pkg/dashboard/api_contribute.go handleContributeReissueToken)#6348
kubestellar-prow[bot] merged 1 commit into
v4from
quality/reissue-token-rotation-tests

Conversation

@kubestellar-hive

Copy link
Copy Markdown
Contributor

Test Improvement

Adds src/pkg/dashboard/contribute_reissue_token_test.go pinning the untested branches of handleContributeReissueToken and reissueContributorToken in src/pkg/dashboard/api_contribute.go — the authenticated credential-rotation endpoint (POST /api/contribute/reissue-token).

Existing tests covered only the two 401 refusals. Newly pinned:

  • Success path rotates for real: new plaintext token returned, profile stores only its sha256 (never plaintext), TokenPlain cleared, old token hash invalidated.
  • Legacy token <t> Authorization scheme accepted alongside Bearer.
  • 404 for authenticated-but-unregistered identities — and no profile file is conjured into existence.
  • 403 for revoked contributors — and the stored credential is NOT rotated, so revocation can't be laundered into a fresh token.
  • 401 for unknown Authorization schemes (e.g. Basic), with the stored token untouched.

Coverage: handleContributeReissueToken 51.9% → 100%; reissueContributorToken → 100%. Tests are hermetic (temp HIVE_CONTRIBUTORS_DIR, mock GitHub /user via the existing v1Server/userMock helpers; unique tokens per test to sidestep the process-wide ghTokenCache).

Overlap preflight

Disjoint from all open hold-gated PRs: #6343 (terminal_handoff), #6342 (github IssueClosedAt), #6330 (agent thrash poller), #6292 (contribute local-mode warning / relay), #6327 (pkg/hub).


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

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

…oard/api_contribute.go handleContributeReissueToken / reissueContributorToken)

Existing tests only pinned the two 401 refusals. This pins the
security-relevant branches: the success path actually rotates (new
plaintext returned, only its sha256 stored, TokenPlain cleared, old hash
invalidated), the legacy 'token <t>' Authorization scheme, 404 for
authenticated-but-unregistered identities (no profile conjured), 403 for
revoked contributors WITHOUT rotating their stored credential, and 401
for unknown Authorization schemes.

Coverage: handleContributeReissueToken 51.9% -> 100%,
reissueContributorToken -> 100%.

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 9, 2026
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Sep 9, 2026
@kubestellar-prow kubestellar-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 9, 2026
@github-actions

github-actions Bot commented Sep 9, 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.

@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 3343b58 into v4 Sep 9, 2026
54 of 58 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the quality/reissue-token-rotation-tests branch September 9, 2026 13:40
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

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

We'd love to hear how your experience was: share feedback

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

Labels

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. hold lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant