Skip to content

fix(registry): make HTTP checks deterministic - #135

Merged
mohit-nagaraj merged 1 commit into
KubeOrch:mainfrom
MagicalCoder-12:fix-registry-deterministic-http
Sep 4, 2026
Merged

mohit-nagaraj merged 1 commit into
KubeOrch:mainfrom
MagicalCoder-12:fix-registry-deterministic-http

Conversation

@MagicalCoder-12

Copy link
Copy Markdown
Contributor

Closes #130

  • Add private injectable httpClient seam (Do(*http.Request) (*http.Response, error)) to RegistryService; NewRegistryService() wires &http.Client{Timeout: 10*time.Second} (existing 10s timeout preserved, verified in test without triggering Mongo panic).
  • Replace 4 inline &http.Client{Timeout: 10*time.Second} in testDockerHubConnection / testGHCRConnection / testACRConnection / testCustomRegistryConnection with s.httpClient.Do.
  • Add deterministic services/registry_service_test.go (314 lines, focused for XS scope): canonical table-driven TestRegistryHTTPConnection_SuccessAndTransportError covering Docker Hub / GHCR / ACR / Custom success (200) + transport error via fakeHTTPClient (no network), plus preserved unique coverage: Docker Hub 401, unexpected 500, Custom no-auth header, GCR JSON validation, dispatch/unsupported type, injected-client wiring, Authorization header format.
  • No real credentials, no external network, no [Registry] Reject invalid credentials for custom registry checks #131/[Registry] Complete bearer-challenge authentication for GHCR checks #132.

Verified: go vet ./services/... and go test ./services/... -count=1 pass.

Signed-off-by: MagicalCoder <kuppamajith@gmail.com>
@coderabbitai

coderabbitai Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 3fa9952f-645d-4713-9ff2-5f65c8c20729

📥 Commits

Reviewing files that changed from the base of the PR and between 5ce2f32 and c9d5143.

📒 Files selected for processing (2)
  • services/registry_service.go
  • services/registry_service_test.go

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Changes

The registry service now uses one injectable private HTTP client with a 10-second production timeout. Tests use a fake client to validate registry requests, transport errors, response handling, dispatch, GCR validation, and authorization headers.

Registry HTTP testing

Layer / File(s) Summary
HTTP client seam and registry checks
services/registry_service.go
RegistryService now stores a private httpClient. The constructor initializes a 10-second http.Client. Docker Hub, GHCR, ACR, and custom registry checks use the shared client.
Deterministic registry connection tests
services/registry_service_test.go
Tests inject a fake client and cover request details, successful and failed responses, transport errors, dispatch, GCR JSON validation, unsupported types, timeout configuration, and Basic authorization headers.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to c9d51

Registry connection checks now use a shared injectable HTTP client while retaining the production timeout. The targeted registry flows have deterministic coverage, and no current merge-readiness risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 17.65% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 17 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: making registry HTTP checks deterministic.
Description check ✅ Passed The description directly explains the injectable HTTP client, timeout preservation, deterministic tests, and verification steps.
Linked Issues check ✅ Passed The changes satisfy issue #130. They add a private injectable HTTP seam, preserve the 10-second production timeout and existing construction, use the seam across all four registry checks, and add netw…
Out of Scope Changes check ✅ Passed The changes remain within issue #130. The additional tests verify existing authentication, status, header, GCR validation, dispatch, and client-wiring behavior without changing those behaviors or unre…
Full details: Linked Issues check

Explanation

The changes satisfy issue #130. They add a private injectable HTTP seam, preserve the 10-second production timeout and existing construction, use the seam across all four registry checks, and add network-free success and transport-error tests without real credentials.

Full details: Out of Scope Changes check

Explanation

The changes remain within issue #130. The additional tests verify existing authentication, status, header, GCR validation, dispatch, and client-wiring behavior without changing those behaviors or unrelated components.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@mohit-nagaraj
mohit-nagaraj merged commit 963a69e into KubeOrch:main Sep 4, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Registry] Add deterministic HTTP test support for connection checks

2 participants