Skip to content

feat(client): add WithHTTPClient option#87

Merged
lidel merged 2 commits into
mainfrom
feat/with-http-client
May 16, 2026
Merged

feat(client): add WithHTTPClient option#87
lidel merged 2 commits into
mainfrom
feat/with-http-client

Conversation

@lidel
Copy link
Copy Markdown
Contributor

@lidel lidel commented May 16, 2026

Note

This makes e2e test harness for autotls possible/simpler in

What was broken

Embedding the forge in a test harness needs a way to override DNS resolution or trust a different CA for the registration endpoint, without losing the PeerID-auth signature scope (which must stay tied to the production registration hostname). client.SendChallenge and P2PForgeCertMgr always used http.DefaultClient, so there was no seam to inject a custom Transport, resolver, or root CA pool.

How this PR fixes it

Adds two options that accept a *http.Client:

  • client.WithHTTPClient(*http.Client) on P2PForgeCertMgr.
  • client.WithChallengeHTTPClient(*http.Client) for client.SendChallenge, which gains a trailing variadic opts ...SendChallengeOption. Existing positional-only callers compile unchanged.

Both options reject nil. The supplied client is threaded through httppeeridauth.ClientPeerIDAuth, so PeerID auth signing wraps the caller's Transport, CheckRedirect, Jar, and Timeout.

Test harnesses that run an in-process forge on a loopback address need
to override resolution or trust a different CA for the registration
endpoint, without losing the PeerID-auth signature scope. The new
WithHTTPClient option lets callers thread a configured *http.Client
through the DNS-01 challenge POST.

SendChallenge keeps its existing signature and forwards to a new
exported SendChallengeWithClient that takes the *http.Client; downstream
callers are unaffected.
@lidel lidel force-pushed the feat/with-http-client branch from 0faa47c to 430ae72 Compare May 16, 2026 13:32
@codecov
Copy link
Copy Markdown

codecov Bot commented May 16, 2026

Codecov Report

❌ Patch coverage is 84.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.05%. Comparing base (f2a4eae) to head (e0f52a7).

Files with missing lines Patch % Lines
client/acme.go 77.77% 1 Missing and 1 partial ⚠️
client/challenge.go 87.50% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #87      +/-   ##
==========================================
+ Coverage   68.31%   69.05%   +0.73%     
==========================================
  Files          21       21              
  Lines        2102     1703     -399     
==========================================
- Hits         1436     1176     -260     
+ Misses        548      409     -139     
  Partials      118      118              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Replace the SendChallengeWithClient variant with a trailing variadic
opts ...SendChallengeOption on SendChallenge. Existing positional-only
callers compile unchanged. The first option, WithChallengeHTTPClient,
threads a caller-supplied *http.Client through the DNS-01 registration
POST.

Add tests covering option validation, the transport wiring through
SendChallenge, and the positional-only backward-compat path.
@ipshipyard ipshipyard deleted a comment from github-actions Bot May 16, 2026
@github-actions
Copy link
Copy Markdown

Suggested tag: v0.8.1

Comparing to: v0.8.0 (diff)

gorelease says:

# summary
v0.8.1 is a valid semantic version for this release.

gocompat says:

HEAD is now at eb86052 chore: v0.8.0 with dependency updates (#86)
Previous HEAD position was eb86052 chore: v0.8.0 with dependency updates (#86)
Switched to branch 'main'
Your branch is up to date with 'origin/main'.

Cutting a Release (and modifying code files)

This PR is modifying both version.json and code files (not markdown, YAML, TOML or lock files).
The Release Checker is not able to analyse files that are not checked in to main. This might cause the above analysis to be inaccurate.
Please consider performing all the code changes in a separate PR before cutting the release.

Automatically created GitHub Release

A draft GitHub Release has been created.
It is going to be published when this PR is merged.
You can modify its' body to include any release notes you wish to include with the release.

@lidel lidel merged commit 6e88a0e into main May 16, 2026
8 checks passed
@lidel lidel deleted the feat/with-http-client branch May 16, 2026 18:54
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.

1 participant