Skip to content

test: cover gitsshsigning resolveKeyFile - #1089

Open
devsy-app[bot] wants to merge 1 commit into
mainfrom
pkg-ssh-git/gitsshsigning-resolvekeyfile-tests
Open

test: cover gitsshsigning resolveKeyFile#1089
devsy-app[bot] wants to merge 1 commit into
mainfrom
pkg-ssh-git/gitsshsigning-resolvekeyfile-tests

Conversation

@devsy-app

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

Copy link
Copy Markdown
Contributor

Package reviewed

pkg/gitsshsigning (SSH/git signing category)

Issue found

The GitSSHSignatureRequest.resolveKeyFile() method — which writes a provided public key to a temp file and returns a cleanup function — had no test coverage of its temp-file lifecycle. The existing server_test.go only covered Sign() failure paths (non-existent key, public-key content error message). Specifically, the following were untested:

  • Temp file is created with the correct public-key content when PublicKey is set.
  • The returned cleanup function actually removes the temp file.
  • When PublicKey is empty, resolveKeyFile returns the original KeyPath and cleanup is a no-op (does not delete the caller's key file).

The last gap is a correctness-sensitive edge case: a buggy cleanup that removed the original key file would silently delete user credentials.

Change

Added three focused tests to pkg/gitsshsigning/server_test.go (no production code changed — test-only):

  • TestResolveKeyFile_PublicKey_CreatesAndCleansTempFile — verifies a temp file is created, its content equals the provided public key, and the resolved path differs from the original KeyPath.
  • TestResolveKeyFile_PublicKey_CleanupRemovesTempFile — verifies the returned cleanup removes the temp file.
  • TestResolveKeyFile_EmptyPublicKey_ReturnsKeyPath — verifies the empty-PublicKey fallback returns KeyPath unchanged and cleanup does not remove the original key file.

No behavioral change; no secrets or key material are printed (only synthetic test keys are used).

Verification performed

  • task cli:format — clean.
  • task cli:lint:ci0 issues (gosec G304 on the test-controlled temp-file read was suppressed with a //nolint:gosec directive; errcheck satisfied via defer func() { _ = f.Close() }()).
  • task cli:testpkg/gitsshsigning passes (ok github.com/devsy-org/devsy/pkg/gitsshsigning).
  • Known pre-existing failures (not caused by this change): pkg/git TestRepoClone* (stale assertion on origin/main) and pkg/docker TestRunCmd_CancelKillsProcessGroup (environment process-group flake, confirmed failing on clean origin/main with changes stashed). Neither package is touched by this PR.

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

Add tests for GitSSHSignatureRequest.resolveKeyFile covering the public-key temp-file creation, content verification, cleanup-on-close, and the empty-public-key fallback to KeyPath.

The existing tests only covered Sign() failure paths; resolveKeyFile had no coverage of its temp-file lifecycle or the no-op cleanup branch.
@netlify

netlify Bot commented Aug 17, 2026

Copy link
Copy Markdown

Deploy Preview for devsydev canceled.

Name Link
🔨 Latest commit 26e8245
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6a82e6d844136000085cee4e

@netlify

netlify Bot commented Aug 17, 2026

Copy link
Copy Markdown

Deploy Preview for images-devsy-sh canceled.

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

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 4 complexity · 0 duplication

Metric Results
Complexity 4
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 marked this pull request as ready for review August 17, 2026 17:25
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.

0 participants