Skip to content

test(image): cover isACRRegistry + ACR helper edges - #1026

Merged
skevetter merged 4 commits into
mainfrom
pkg-container/acr-registry-detection-tests
Aug 18, 2026
Merged

test(image): cover isACRRegistry + ACR helper edges#1026
skevetter merged 4 commits into
mainfrom
pkg-container/acr-registry-detection-tests

Conversation

@devsy-app

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

Copy link
Copy Markdown
Contributor

Package reviewed

pkg/image (container/Docker category) � specifically acr.go, the Azure Container Registry credential handling.

Issue found

isACRRegistry � the pure function that decides whether a server URL is an ACR/MCR registry (so the credential helper routes to Azure exchange auth instead of the default keychain) � had 0% coverage. Its regex (^.+\.azurecr\.(io|cn|de|us)$) plus the mcr.microsoft.com special-case and port-suffixed host parsing had no tests, so a regression that mis-routed a non-ACR registry to Azure auth (or dropped a sovereign-cloud TLD) would not be caught. The ACR credential helper's non-ACR rejection path and its unimplemented Add/Delete/List mutation methods were also untested.

Change

Added pkg/image/acr_test.go (test-only, no behavioral change):

  • TestIsACRRegistry â�� table-driven cases covering all four ACR TLDs (io/cn/de/us), mcr.microsoft.com, port-suffixed hosts (foo.azurecr.io:443), and rejections: Docker Hub, GHCR, bare azurecr.io apex, wrong TLD (azurecr.com), lookalike (notazurecr.io), and empty input.
  • TestACRCredHelper_GetRejectsNonACRRegistry â�� asserts Get rejects a non-ACR registry (e.g. docker.io) locally with a clear "Azure Container Registry" error and returns empty credentials, without touching the network or Azure tokens.
  • TestACRCredHelper_UnimplementedMutations â�� asserts Add/Delete/List report unimplemented rather than silently succeeding.
  • TestNewACRCredentialsHelperSatisfiesInterface â�� confirms the constructor returns a value satisfying credentials.Helper.

Coverage impact: isACRRegistry 0% � 83.3% (remaining branch is the url.Parse error path, unreachable for valid https://-prefixed inputs); package pkg/image 17.7% � 23.4%.

Verification performed

  • task cli:format â�� clean (no changes to the new file)
  • task cli:lint:ci â�� 0 issues
  • task cli:test â�� pkg/image passes. The only failure is pkg/git (TestRepoClone*), a known pre-existing stale-assertion failure on origin/main, unrelated to this change (this PR does not touch pkg/git).
  • go test ./pkg/image/ â�� PASS

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

Add edge-case tests for pkg/image ACR credential handling. isACRRegistry was at 0% coverage; cover its regex (all 4 azure TLDs, mcr.microsoft.com), port-suffixed hosts, apex/wrong-TLD/lookalike rejections, and empty input. Also assert the ACR cred helper rejects non-ACR registries locally (no network), and that Add/Delete/List report unimplemented. Package coverage 17.7% -> 23.4%.
@netlify

netlify Bot commented Aug 13, 2026

Copy link
Copy Markdown

Deploy Preview for devsydev ready!

Name Link
🔨 Latest commit e699964
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6a83db1478b0e80008a09b29
😎 Deploy Preview https://deploy-preview-1026--devsydev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Aug 13, 2026

Copy link
Copy Markdown

Deploy Preview for images-devsy-sh ready!

Name Link
🔨 Latest commit e699964
🔍 Latest deploy log https://app.netlify.com/projects/images-devsy-sh/deploys/6a83db143536c30008a6d87e
😎 Deploy Preview https://deploy-preview-1026--images-devsy-sh.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@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.

devsy-app Bot and others added 2 commits August 13, 2026 16:36
Use a short variable declaration in TestNewACRCredentialsHelperSatisfiesInterface; newACRCredentialsHelper already returns credentials.Helper, so the explicit type is redundant (staticcheck ST1023). Lint fix only; no behavior change.

This commit was created by an AI agent (OpenHands) on behalf of the user.
@skevetter
skevetter marked this pull request as ready for review August 18, 2026 04:09
@mergify

mergify Bot commented Aug 18, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@skevetter
skevetter merged commit ff1d31d into main Aug 18, 2026
78 checks passed
@skevetter
skevetter deleted the pkg-container/acr-registry-detection-tests branch August 18, 2026 06:20
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