chore(ari): use doer instead of raw HTTP client

This commit is contained in:
Fernandez Ludovic 2026-03-05 18:02:45 +01:00
commit 833f100d6a
2 changed files with 4 additions and 18 deletions

View file

@ -5,10 +5,8 @@ import (
"crypto/x509"
"encoding/asn1"
"encoding/base64"
"encoding/json"
"errors"
"fmt"
"net/http"
"github.com/go-acme/lego/v5/acme"
)
@ -32,25 +30,15 @@ func (c *CertificateService) GetRenewalInfo(ctx context.Context, certID string)
return nil, errors.New("renewalInfo[get]: 'certID' cannot be empty")
}
req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.core.GetDirectory().RenewalInfo+"/"+certID, nil)
if err != nil {
return nil, err
}
info := new(acme.ExtendedRenewalInfo)
resp, err := c.core.HTTPClient.Do(req)
resp, err := c.core.doer.Get(ctx, c.core.GetDirectory().RenewalInfo+"/"+certID, info)
if err != nil {
return nil, err
}
defer func() { _ = resp.Body.Close() }()
info := new(acme.ExtendedRenewalInfo)
err = json.NewDecoder(resp.Body).Decode(info)
if err != nil {
return nil, err
}
if retry := resp.Header.Get("Retry-After"); retry != "" {
info.RetryAfter, err = ParseRetryAfter(retry)
if err != nil {

View file

@ -50,8 +50,7 @@ func TestCertificateService_GetRenewalInfo(t *testing.T) {
"end": "2020-03-17T18:21:09Z"
},
"explanationUrl": "https://aricapable.ca.example/docs/renewal-advice/"
}
}`).
}`).
WithHeader("Content-Type", "application/json").
WithHeader("Retry-After", "21600")).
BuildHTTPS(t)
@ -83,8 +82,7 @@ func TestCertificateService_GetRenewalInfo_retryAfter(t *testing.T) {
"end": "2020-03-17T18:21:09Z"
},
"explanationUrl": "https://aricapable.ca.example/docs/renewal-advice/"
}
}`).
}`).
WithHeader("Content-Type", "application/json").
WithHeader("Retry-After", time.Now().UTC().Add(6*time.Hour).Format(time.RFC1123))).
BuildHTTPS(t)