@@ -33,6 +33,7 @@ import (
3333 "github.com/letsencrypt/boulder/bdns"
3434 "github.com/letsencrypt/boulder/cmd"
3535 "github.com/letsencrypt/boulder/core"
36+ "github.com/letsencrypt/boulder/features"
3637 blog "github.com/letsencrypt/boulder/log"
3738 "github.com/letsencrypt/boulder/metrics"
3839 "github.com/letsencrypt/boulder/metrics/mock_metrics"
@@ -378,33 +379,58 @@ func TestHTTPTimeout(t *testing.T) {
378379 // TODO(#1989): close hs
379380
380381 va , _ := setup (hs , 0 )
381-
382382 setChallengeToken (& chall , pathWaitLong )
383- started := time .Now ()
384383
385- timeout := 50 * time .Millisecond
386- ctx , cancel := context .WithTimeout (context .Background (), timeout )
387- defer cancel ()
384+ testCases := []struct {
385+ Name string
386+ SimplifiedVAHTTP bool
387+ }{
388+ {"Legacy VA HTTP" , false },
389+ {"Simplified VA HTTP" , true },
390+ }
391+
392+ for _ , tc := range testCases {
393+ t .Run (tc .Name , func (t * testing.T ) {
394+ var expectMatch * regexp.Regexp
395+ expectMatch = regexp .MustCompile (
396+ "Fetching http://localhost:\\ d+/.well-known/acme-challenge/wait-long: Timeout after connect" )
397+
398+ if tc .SimplifiedVAHTTP {
399+ err := features .Set (map [string ]bool {"SimplifiedVAHTTP" : true })
400+ test .AssertNotError (t , err , "Failed to set SimplifiedVAHTTP feature flag" )
401+ defer features .Reset ()
402+ // Simplified VA HTTP error messages don't include the port number when
403+ // it is equal to the va http port since it is implied by the `http://`
404+ // protocol prefix.
405+ expectMatch = regexp .MustCompile (
406+ "Fetching http://localhost/.well-known/acme-challenge/wait-long: Timeout after connect" )
407+ }
388408
389- _ , prob := va .validateHTTP01 (ctx , dnsi ("localhost" ), chall )
390- if prob == nil {
391- t .Fatalf ("Connection should've timed out" )
392- }
393- took := time .Since (started )
394- // Check that the HTTP connection doesn't return before a timeout, and times
395- // out after the expected time
396- if took < timeout {
397- t .Fatalf ("HTTP timed out before %s: %s with %s" , timeout , took , prob )
398- }
399- if took > 2 * timeout {
400- t .Fatalf ("HTTP connection didn't timeout after %s" , timeout )
401- }
402- test .AssertEquals (t , prob .Type , probs .ConnectionProblem )
403- expectMatch := regexp .MustCompile (
404- "Fetching http://localhost:\\ d+/.well-known/acme-challenge/wait-long: Timeout after connect" )
405- if ! expectMatch .MatchString (prob .Detail ) {
406- t .Errorf ("Problem details incorrect. Got %q, expected to match %q" ,
407- prob .Detail , expectMatch )
409+ started := time .Now ()
410+ timeout := 50 * time .Millisecond
411+ ctx , cancel := context .WithTimeout (context .Background (), timeout )
412+ defer cancel ()
413+ _ , prob := va .validateHTTP01 (ctx , dnsi ("localhost" ), chall )
414+ if prob == nil {
415+ t .Fatalf ("Connection should've timed out" )
416+ }
417+
418+ took := time .Since (started )
419+ // Check that the HTTP connection doesn't return before a timeout, and times
420+ // out after the expected time
421+ if took < timeout {
422+ t .Fatalf ("HTTP timed out before %s: %s with %s" , timeout , took , prob )
423+ }
424+ if took > 2 * timeout {
425+ t .Fatalf ("HTTP connection didn't timeout after %s" , timeout )
426+ }
427+ test .AssertEquals (t , prob .Type , probs .ConnectionProblem )
428+
429+ if ! expectMatch .MatchString (prob .Detail ) {
430+ t .Errorf ("Problem details incorrect. Got %q, expected to match %q" ,
431+ prob .Detail , expectMatch )
432+ }
433+ })
408434 }
409435}
410436
0 commit comments