Skip to content

test(dockercredentials): cover auth token helpers - #970

Merged
skevetter merged 2 commits into
mainfrom
pkg-container/dockercredentials-tests
Aug 9, 2026
Merged

skevetter merged 2 commits into
mainfrom
pkg-container/dockercredentials-tests

Conversation

@devsy-app

@devsy-app devsy-app Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Package reviewed

pkg/dockercredentials (credential handling — Docker/OCI registry auth).

Issue found

The pure credential-transformation helpers on the registry auth path were entirely untested:

  • Credentials.AuthToken() — formats the username:secret pair used by the kubernetes pull-secret sync (pkg/driver/kubernetes/pullsecrets.go). The username-present vs. username-absent branches had no coverage.
  • credentialsFromAuthConfig() — converts a docker types.AuthConfig into the internal Credentials, including the non-obvious precedence rule where IdentityToken overrides Password as the secret. That precedence was untested.
  • fillFromContainerCredentials() — early-return path when the docker SDK already returned populated credentials.

These functions sit on the critical pull-secret auth path, and the IdentityToken-over-Password precedence is exactly the kind of non-obvious invariant that silently breaks if refactored.

Change

Added pkg/dockercredentials/credentials_test.go covering the above branches (no behavioral change, test-only):

  • AuthToken: username+secret pair, secret-only fallback, empty case.
  • credentialsFromAuthConfig: password default, identity-token precedence, empty input.
  • fillFromContainerCredentials: returns existing populated auth config unchanged.

No credentials are printed; tests use synthetic values only.

Verification performed

  • task cli:format — clean.
  • task cli:lint:ci — 0 new issues.
  • task cli:test — passes; the only failing package is pkg/git (TestRepoClone*), the known pre-existing stale-assertion failure on origin/main, unrelated to this change (which only touches pkg/dockercredentials).
  • go test ./pkg/dockercredentials/... — ok.

This PR was created by an AI agent as part of an automated daily package review job.

@netlify

netlify Bot commented Aug 9, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for devsydev canceled.

Name Link
🔨 Latest commit f997684
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6a78f9cc17d17400082a0c6e

@netlify

netlify Bot commented Aug 9, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for images-devsy-sh canceled.

Name Link
🔨 Latest commit f997684
🔍 Latest deploy log https://app.netlify.com/projects/images-devsy-sh/deploys/6a78f9cc6834390008e85727

@github-actions github-actions Bot added the size/m label Aug 9, 2026
@skevetter
skevetter marked this pull request as ready for review August 9, 2026 21:59
@skevetter
skevetter enabled auto-merge (squash) August 9, 2026 21:59
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 8 complexity · 0 duplication

Metric Results
Complexity 8
Duplication 0

View in Codacy

AI Reviewer: run a review on demand. To trigger the first review automatically, go to your organization or repository integration settings. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

@skevetter
skevetter merged commit 2cc35f7 into main Aug 9, 2026
67 checks passed
@skevetter
skevetter deleted the pkg-container/dockercredentials-tests branch August 9, 2026 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant