@@ -103,6 +103,9 @@ func createValidationRequest(domain string, challengeType core.AcmeChallenge) *v
103103
104104// setup returns an in-memory VA and a mock logger. The default resolver client
105105// is MockClient{}, but can be overridden.
106+ //
107+ // If remoteVAs is nil, this builds a VA that acts like a remote (and does not
108+ // perform multi-perspective validation). Otherwise it acts like a primary.
106109func setup (srv * httptest.Server , userAgent string , remoteVAs []RemoteVA , mockDNSClientOverride bdns.Client ) (* ValidationAuthorityImpl , * blog.Mock ) {
107110 features .Reset ()
108111 fc := clock .NewFake ()
@@ -113,6 +116,13 @@ func setup(srv *httptest.Server, userAgent string, remoteVAs []RemoteVA, mockDNS
113116 userAgent = "user agent 1.0"
114117 }
115118
119+ perspective := PrimaryPerspective
120+ if len (remoteVAs ) == 0 {
121+ // We're being set up as a remote. Use a distinct perspective from other remotes
122+ // to better simulate what prod will be like.
123+ perspective = "example perspective " + core .RandomString (4 )
124+ }
125+
116126 va , err := NewValidationAuthorityImpl (
117127 & bdns.MockClient {Log : logger },
118128 remoteVAs ,
@@ -122,9 +132,12 @@ func setup(srv *httptest.Server, userAgent string, remoteVAs []RemoteVA, mockDNS
122132 fc ,
123133 logger ,
124134 accountURIPrefixes ,
125- PrimaryPerspective ,
135+ perspective ,
126136 "" ,
127137 )
138+ if err != nil {
139+ panic (fmt .Sprintf ("Failed to create validation authority: %v" , err ))
140+ }
128141
129142 if mockDNSClientOverride != nil {
130143 va .dnsClient = mockDNSClientOverride
@@ -138,9 +151,6 @@ func setup(srv *httptest.Server, userAgent string, remoteVAs []RemoteVA, mockDNS
138151 va .tlsPort = port
139152 }
140153
141- if err != nil {
142- panic (fmt .Sprintf ("Failed to create validation authority: %v" , err ))
143- }
144154 return va , logger
145155}
146156
@@ -255,7 +265,7 @@ func TestPerformValidationInvalid(t *testing.T) {
255265 test .Assert (t , res .Problems != nil , "validation succeeded" )
256266 test .AssertMetricWithLabelsEquals (t , va .metrics .validationLatency , prometheus.Labels {
257267 "operation" : opChallAndCAA ,
258- "perspective" : PrimaryPerspective ,
268+ "perspective" : va . perspective ,
259269 "challenge_type" : string (core .ChallengeTypeDNS01 ),
260270 "problem_type" : string (probs .UnauthorizedProblem ),
261271 "result" : fail ,
@@ -285,7 +295,7 @@ func TestPerformValidationValid(t *testing.T) {
285295
286296 test .AssertMetricWithLabelsEquals (t , va .metrics .validationLatency , prometheus.Labels {
287297 "operation" : opChallAndCAA ,
288- "perspective" : PrimaryPerspective ,
298+ "perspective" : va . perspective ,
289299 "challenge_type" : string (core .ChallengeTypeDNS01 ),
290300 "problem_type" : "" ,
291301 "result" : pass ,
@@ -312,7 +322,7 @@ func TestPerformValidationWildcard(t *testing.T) {
312322
313323 test .AssertMetricWithLabelsEquals (t , va .metrics .validationLatency , prometheus.Labels {
314324 "operation" : opChallAndCAA ,
315- "perspective" : PrimaryPerspective ,
325+ "perspective" : va . perspective ,
316326 "challenge_type" : string (core .ChallengeTypeDNS01 ),
317327 "problem_type" : "" ,
318328 "result" : pass ,
@@ -422,15 +432,6 @@ func TestMultiVA(t *testing.T) {
422432 AllowedUAs : map [string ]bool {remoteUA1 : true , remoteUA2 : true },
423433 ExpectedProb : unauthorized ,
424434 },
425- {
426- // If one out of two remote VAs fail with an internal err it should succeed
427- Name : "Local VA ok, 1/2 remote VA internal err" ,
428- RemoteVAs : []RemoteVA {
429- {remoteVA1 , remoteUA1 },
430- {brokenVA , "broken" },
431- },
432- AllowedUAs : allowedUAs ,
433- },
434435 {
435436 // If one out of three remote VAs fails with an internal err it should succeed
436437 Name : "Local VA ok, 1/3 remote VA internal err" ,
@@ -530,12 +531,12 @@ func TestMultiVA(t *testing.T) {
530531 AllowedUAs : allowedUAs ,
531532 },
532533 {
533- // If two remote VA cancels , it should fail
534- Name : "Local VA OK, two cancelled remote VAs" ,
534+ // If all remote VAs cancel , it should fail
535+ Name : "Local VA OK, three cancelled remote VAs" ,
535536 RemoteVAs : []RemoteVA {
536- {remoteVA1 , remoteUA1 },
537537 {cancelledVA , remoteUA1 },
538538 {cancelledVA , remoteUA2 },
539+ {cancelledVA , remoteUA3 },
539540 },
540541 AllowedUAs : allowedUAs ,
541542 ExpectedProb : probs .ServerInternal ("During secondary validation: Remote PerformValidation RPC canceled" ),
@@ -645,24 +646,28 @@ func TestMultiVAPolicy(t *testing.T) {
645646 const (
646647 remoteUA1 = "remote 1"
647648 remoteUA2 = "remote 2"
649+ remoteUA3 = "remote 3"
648650 localUA = "local 1"
649651 )
650- // Forbid both remote UAs to ensure that multi-va fails
652+ // Forbid all remote UAs to ensure that multi-va fails
651653 allowedUAs := map [string ]bool {
652654 localUA : true ,
653655 remoteUA1 : false ,
654656 remoteUA2 : false ,
657+ remoteUA3 : false ,
655658 }
656659
657660 ms := httpMultiSrv (t , expectedToken , allowedUAs )
658661 defer ms .Close ()
659662
660663 remoteVA1 := setupRemote (ms .Server , remoteUA1 , nil , "" , "" )
661664 remoteVA2 := setupRemote (ms .Server , remoteUA2 , nil , "" , "" )
665+ remoteVA3 := setupRemote (ms .Server , remoteUA3 , nil , "" , "" )
662666
663667 remoteVAs := []RemoteVA {
664668 {remoteVA1 , remoteUA1 },
665669 {remoteVA2 , remoteUA2 },
670+ {remoteVA3 , remoteUA3 },
666671 }
667672
668673 // Create a local test VA with the two remote VAs
@@ -681,6 +686,7 @@ func TestMultiVALogging(t *testing.T) {
681686 const (
682687 rva1UA = "remote 1"
683688 rva2UA = "remote 2"
689+ rva3UA = "remote 3"
684690 localUA = "local 1"
685691 )
686692
@@ -689,10 +695,12 @@ func TestMultiVALogging(t *testing.T) {
689695
690696 rva1 := setupRemote (ms .Server , rva1UA , nil , "dev-arin" , "ARIN" )
691697 rva2 := setupRemote (ms .Server , rva2UA , nil , "dev-ripe" , "RIPE" )
698+ rva3 := setupRemote (ms .Server , rva3UA , nil , "dev-ripe" , "RIPE" )
692699
693700 remoteVAs := []RemoteVA {
694701 {rva1 , rva1UA },
695702 {rva2 , rva2UA },
703+ {rva3 , rva3UA },
696704 }
697705 va , _ := setup (ms .Server , localUA , remoteVAs , nil )
698706 req := createValidationRequest ("letsencrypt.org" , core .ChallengeTypeHTTP01 )
0 commit comments