Skip to content

test: cover pkg/ssh key management - #1011

Merged
skevetter merged 1 commit into
mainfrom
pkg-ssh-git/keys-test-coverage
Aug 12, 2026
Merged

skevetter merged 1 commit into
mainfrom
pkg-ssh-git/keys-test-coverage

Conversation

@devsy-app

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

Copy link
Copy Markdown
Contributor

Summary

Adds unit tests for pkg/ssh/keys.go covering the three key-management helpers: GetPrivateKeyRawBase, GetPublicKeyBase, and GetHostKeyBase.

Package reviewed

pkg/ssh (SSH/git/credentials category).

Issue found

pkg/ssh/keys.go had no test coverage for its key generation/persistence helpers. The functions generate an ED25519 key pair, write the private key (PEM, 0600) and public key (authorized-keys format, 0644) to disk, and return their base paths. Edge cases — idempotency across repeated calls, public/private correspondence, file permissions, and missing base-directory creation — were unverified.

Change

New file pkg/ssh/keys_test.go with table-driven tests asserting:

  • key generation produces a valid PEM private key and an authorized-keys public key
  • the public key corresponds to the private key (fingerprint match)
  • private key files are 0600, public key files are 0644
  • generation is idempotent: calling twice returns the same paths without error
  • a missing base directory is created automatically

No behavioral changes to production code; tests only.

Verification

  • task cli:lint:ci — 0 new issues
  • task cli:test — focused pkg/ssh tests pass (known pre-existing pkg/git TestRepoClone* failures on origin/main are unrelated and not touched by this change)

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

Add unit tests for pkg/ssh/keys.go covering GetPrivateKeyRawBase,
GetPublicKeyBase, and GetHostKeyBase. Tests assert key generation
produces valid PEM/authorized-key pairs, that public and private keys
correspond, file permissions are 0600/0644, key generation is
idempotent across calls, and missing base directories are created.
@netlify

netlify Bot commented Aug 12, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for devsydev canceled.

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

@netlify

netlify Bot commented Aug 12, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for images-devsy-sh canceled.

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

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 6 complexity · 2 duplication

Metric Results
Complexity 6
Duplication 2

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 12, 2026 14:36
@skevetter
skevetter merged commit ca19ad5 into main Aug 12, 2026
67 checks passed
@skevetter
skevetter deleted the pkg-ssh-git/keys-test-coverage branch August 12, 2026 15:49
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