Skip to content

Commit

Permalink
VA: Remove unnecessary wrapper function (#7997)
Browse files Browse the repository at this point in the history
This function lost its purpose when we made it so all VA functions
return errors instead of problems in
#7313.
  • Loading branch information
aarongable authored Feb 5, 2025
1 parent eda4966 commit f66d030
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
16 changes: 1 addition & 15 deletions va/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,20 +382,6 @@ func (va *ValidationAuthorityImpl) setupHTTPValidation(
return dialer, record, nil
}

// fetchHTTP invokes processHTTPValidation and if an error result is
// returned, converts it to a problem. Otherwise the results from
// processHTTPValidation are returned.
func (va *ValidationAuthorityImpl) fetchHTTP(
ctx context.Context,
host string,
path string) ([]byte, []core.ValidationRecord, error) {
body, records, err := va.processHTTPValidation(ctx, host, path)
if err != nil {
return body, records, err
}
return body, records, nil
}

// fallbackErr returns true only for net.OpError instances where the op is equal
// to "dial", or url.Error instances wrapping such an error. fallbackErr returns
// false for all other errors. By policy, only dial errors (not read or write
Expand Down Expand Up @@ -647,7 +633,7 @@ func (va *ValidationAuthorityImpl) validateHTTP01(ctx context.Context, ident ide

// Perform the fetch
path := fmt.Sprintf(".well-known/acme-challenge/%s", token)
body, validationRecords, err := va.fetchHTTP(ctx, ident.Value, "/"+path)
body, validationRecords, err := va.processHTTPValidation(ctx, ident.Value, "/"+path)
if err != nil {
return validationRecords, err
}
Expand Down
8 changes: 4 additions & 4 deletions va/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func TestDialerTimeout(t *testing.T) {
var took time.Duration
for range 20 {
started := time.Now()
_, _, err = va.fetchHTTP(ctx, "unroutable.invalid", "/.well-known/acme-challenge/whatever")
_, _, err = va.processHTTPValidation(ctx, "unroutable.invalid", "/.well-known/acme-challenge/whatever")
took = time.Since(started)
if err != nil && strings.Contains(err.Error(), "network is unreachable") {
continue
Expand Down Expand Up @@ -322,7 +322,7 @@ func TestExtractRequestTarget(t *testing.T) {
func TestHTTPValidationDNSError(t *testing.T) {
va, mockLog := setup(nil, "", nil, nil)

_, _, prob := va.fetchHTTP(ctx, "always.error", "/.well-known/acme-challenge/whatever")
_, _, prob := va.processHTTPValidation(ctx, "always.error", "/.well-known/acme-challenge/whatever")
test.AssertError(t, prob, "Expected validation fetch to fail")
matchingLines := mockLog.GetAllMatching(`read udp: some net error`)
if len(matchingLines) != 1 {
Expand All @@ -338,7 +338,7 @@ func TestHTTPValidationDNSError(t *testing.T) {
func TestHTTPValidationDNSIdMismatchError(t *testing.T) {
va, mockLog := setup(nil, "", nil, nil)

_, _, prob := va.fetchHTTP(ctx, "id.mismatch", "/.well-known/acme-challenge/whatever")
_, _, prob := va.processHTTPValidation(ctx, "id.mismatch", "/.well-known/acme-challenge/whatever")
test.AssertError(t, prob, "Expected validation fetch to fail")
matchingLines := mockLog.GetAllMatching(`logDNSError ID mismatch`)
if len(matchingLines) != 1 {
Expand Down Expand Up @@ -1105,7 +1105,7 @@ func TestFetchHTTP(t *testing.T) {
t.Run(tc.Name, func(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*500)
defer cancel()
body, records, err := va.fetchHTTP(ctx, tc.Host, tc.Path)
body, records, err := va.processHTTPValidation(ctx, tc.Host, tc.Path)
if tc.ExpectedProblem == nil {
test.AssertNotError(t, err, "expected nil prob")
} else {
Expand Down

0 comments on commit f66d030

Please sign in to comment.