Skip to content

test: cover credential helper script gen - #981

Merged
skevetter merged 2 commits into
mainfrom
pkg-container/credential-helper-tests
Aug 11, 2026
Merged

skevetter merged 2 commits into
mainfrom
pkg-container/credential-helper-tests

Conversation

@devsy-app

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

Copy link
Copy Markdown
Contributor

Package reviewed

pkg/dockercredentials — Docker credential helper configuration (scope: container/Docker category).

Issue found

buildHelperContent (and the related unexported helpers newDockerCredentialsDir and appendToPath) had zero test coverage. buildHelperContent generates the executable credential-helper script that Docker invokes to fetch registry credentials, and it branches on runtime.GOOS to produce a Unix (#!/bin/sh) or Windows (@echo off) script, quoting a caller-supplied binary path. Because it writes an executable invoked by Docker with credential forwarding, silent regressions in its format (wrong subcommand, missing quoting, wrong line endings, dropped port) would be hard to catch without tests.

Change

Add pkg/dockercredentials/helper_content_test.go (test-only, no behavioral change) covering:

  • Unix variant: shebang on its own line, embedded binary path, literal internal agent docker-credentials subcommand, --port <N>, "$@" passthrough, trailing newline, LF line endings (no CR).
  • Windows variant: @echo off prefix, double-quoted binary path, the same subcommand/--port/%* passthrough, trailing CRLF.
  • Quoting of a Unix binary path containing a space (single-quoted form, and that the unquoted path does not leak adjacent to internal).
  • Windows %-doubling in the binary path (literal % becomes %% so cmd does not expand it).
  • Port embedding across boundary values (0, 1, 65535).
  • newDockerCredentialsDir naming prefix and 12-char random suffix length.
  • appendToPath appends the directory to PATH with the platform separator.

Platform-specific cases skip on the wrong OS so the suite is green on Linux CI (the unix cases run; the windows cases skip).

Verification performed

  • task cli:format — clean (no formatting changes).
  • task cli:lint:ci — 0 issues.
  • task cli:test — pkg/dockercredentials passes; the only failing package is pkg/git (TestRepoClone*), the documented pre-existing failure on origin/main, unrelated to this change (this PR does not touch pkg/git).
  • Focused run: go test ./pkg/dockercredentials/ -run TestHelperContentSuite -v — all non-skipped cases PASS.

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

Add tests for pkg/dockercredentials buildHelperContent covering unix and windows credential-helper script generation: shebang/echo prefix, embedded port, the literal 'internal agent docker-credentials' subcommand, LF vs CRLF line endings, single-quote quoting of binary paths with spaces, and windows percent-doubling. Also covers newDockerCredentialsDir naming/length and appendToPath PATH extension. These functions had zero test coverage; no behavioral change.
@netlify

netlify Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for devsydev canceled.

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

@netlify

netlify Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for images-devsy-sh canceled.

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

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 16 complexity · 0 duplication

Metric Results
Complexity 16
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.

Signed-off-by: Samuel K <skevetter@pm.me>
@skevetter
skevetter marked this pull request as ready for review August 11, 2026 05:23
@skevetter
skevetter enabled auto-merge (squash) August 11, 2026 05:23
@skevetter
skevetter merged commit 4d96ef1 into main Aug 11, 2026
67 checks passed
@skevetter
skevetter deleted the pkg-container/credential-helper-tests branch August 11, 2026 05:52
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