Skip to content

Commit 27a7714

Browse files
VA: Make performRemoteValidation more generic (#7847)
- Make performRemoteValidation a more generic function that returns a new remoteResult interface - Modify the return value of IsCAAValid and PerformValidation to satisfy the remoteResult interface - Include compile time checks and tests that pass an arbitrary operation
1 parent ded2e5e commit 27a7714

File tree

9 files changed

+215
-100
lines changed

9 files changed

+215
-100
lines changed

grpc/pb-marshalling.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,13 @@ func ValidationResultToPB(records []core.ValidationRecord, prob *probs.ProblemDe
188188
return nil, err
189189
}
190190
}
191-
marshalledProbs, err := ProblemDetailsToPB(prob)
191+
marshalledProb, err := ProblemDetailsToPB(prob)
192192
if err != nil {
193193
return nil, err
194194
}
195195
return &vapb.ValidationResult{
196196
Records: recordAry,
197-
Problems: marshalledProbs,
197+
Problem: marshalledProb,
198198
Perspective: perspective,
199199
Rir: rir,
200200
}, nil
@@ -212,7 +212,7 @@ func pbToValidationResult(in *vapb.ValidationResult) ([]core.ValidationRecord, *
212212
return nil, nil, err
213213
}
214214
}
215-
prob, err := PBToProblemDetails(in.Problems)
215+
prob, err := PBToProblemDetails(in.Problem)
216216
if err != nil {
217217
return nil, nil, err
218218
}

ra/ra.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,7 +1762,7 @@ func (ra *RegistrationAuthorityImpl) recordValidation(ctx context.Context, authI
17621762
Attempted: string(challenge.Type),
17631763
AttemptedAt: validated,
17641764
ValidationRecords: vr.Records,
1765-
ValidationError: vr.Problems,
1765+
ValidationError: vr.Problem,
17661766
})
17671767
return err
17681768
}
@@ -1929,8 +1929,8 @@ func (ra *RegistrationAuthorityImpl) PerformValidation(
19291929
prob = probs.ServerInternal("Could not communicate with VA")
19301930
ra.log.AuditErrf("Could not communicate with VA: %s", err)
19311931
} else {
1932-
if res.Problems != nil {
1933-
prob, err = bgrpc.PBToProblemDetails(res.Problems)
1932+
if res.Problem != nil {
1933+
prob, err = bgrpc.PBToProblemDetails(res.Problem)
19341934
if err != nil {
19351935
prob = probs.ServerInternal("Could not communicate with VA")
19361936
ra.log.AuditErrf("Could not communicate with VA: %s", err)

ra/ra_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ func TestPerformValidationAlreadyValid(t *testing.T) {
728728
Url: "http://example.com/",
729729
},
730730
},
731-
Problems: nil,
731+
Problem: nil,
732732
}
733733

734734
// A subsequent call to perform validation should return nil due
@@ -758,7 +758,7 @@ func TestPerformValidationSuccess(t *testing.T) {
758758
ResolverAddrs: []string{"rebound"},
759759
},
760760
},
761-
Problems: nil,
761+
Problem: nil,
762762
}
763763

764764
now := fc.Now()
@@ -901,7 +901,7 @@ func TestPerformValidation_FailedValidationsTriggerPauseIdentifiersRatelimit(t *
901901
ResolverAddrs: []string{"rebound"},
902902
},
903903
},
904-
Problems: &corepb.ProblemDetails{
904+
Problem: &corepb.ProblemDetails{
905905
Detail: fmt.Sprintf("CAA invalid for %s", domain),
906906
},
907907
}
@@ -954,7 +954,7 @@ func TestPerformValidation_FailedValidationsTriggerPauseIdentifiersRatelimit(t *
954954
ResolverAddrs: []string{"rebound"},
955955
},
956956
},
957-
Problems: &corepb.ProblemDetails{
957+
Problem: &corepb.ProblemDetails{
958958
Detail: fmt.Sprintf("CAA invalid for %s", domain),
959959
},
960960
}
@@ -1034,7 +1034,7 @@ func TestPerformValidation_FailedThenSuccessfulValidationResetsPauseIdentifiersR
10341034
ResolverAddrs: []string{"rebound"},
10351035
},
10361036
},
1037-
Problems: &corepb.ProblemDetails{
1037+
Problem: &corepb.ProblemDetails{
10381038
Detail: fmt.Sprintf("CAA invalid for %s", domain),
10391039
},
10401040
}
@@ -1092,7 +1092,7 @@ func TestPerformValidation_FailedThenSuccessfulValidationResetsPauseIdentifiersR
10921092
ResolverAddrs: []string{"rebound"},
10931093
},
10941094
},
1095-
Problems: nil,
1095+
Problem: nil,
10961096
}
10971097

10981098
challIdx = dnsChallIdx(t, authzPB.Challenges)

test/v2_integration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,8 +1083,8 @@ def test_http_multiva_threshold_fail():
10831083
raise(Exception("no HTTP-01 challenge in failed authz"))
10841084
if httpChall.error.typ != "urn:ietf:params:acme:error:unauthorized":
10851085
raise(Exception("expected unauthorized prob, found {0}".format(httpChall.error.typ)))
1086-
if not httpChall.error.detail.startswith("During secondary domain validation: "):
1087-
raise(Exception("expected 'During secondary domain validation' problem detail, found {0}".format(httpChall.error.detail)))
1086+
if not httpChall.error.detail.startswith("During secondary validation: "):
1087+
raise(Exception("expected 'During secondary validation' problem detail, found {0}".format(httpChall.error.detail)))
10881088

10891089
class FakeH2ServerHandler(socketserver.BaseRequestHandler):
10901090
"""

va/dns_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ func TestDNSValidationEmpty(t *testing.T) {
2525
// metrics checked below are incremented.
2626
req := createValidationRequest("empty-txts.com", core.ChallengeTypeDNS01)
2727
res, _ := va.PerformValidation(context.Background(), req)
28-
test.AssertEquals(t, res.Problems.ProblemType, "unauthorized")
29-
test.AssertEquals(t, res.Problems.Detail, "No TXT record found at _acme-challenge.empty-txts.com")
28+
test.AssertEquals(t, res.Problem.ProblemType, "unauthorized")
29+
test.AssertEquals(t, res.Problem.Detail, "No TXT record found at _acme-challenge.empty-txts.com")
3030

3131
test.AssertMetricWithLabelsEquals(t, va.metrics.validationLatency, prometheus.Labels{
3232
"operation": opChallAndCAA,

va/proto/va.pb.go

Lines changed: 65 additions & 46 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

va/proto/va.proto

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ message IsCAAValidRequest {
2323
// If CAA is valid for the requested domain, the problem will be empty
2424
message IsCAAValidResponse {
2525
core.ProblemDetails problem = 1;
26+
string perspective = 3;
27+
string rir = 4;
2628
}
2729

2830
message PerformValidationRequest {
@@ -39,7 +41,7 @@ message AuthzMeta {
3941

4042
message ValidationResult {
4143
repeated core.ValidationRecord records = 1;
42-
core.ProblemDetails problems = 2;
44+
core.ProblemDetails problem = 2;
4345
string perspective = 3;
4446
string rir = 4;
4547
}

0 commit comments

Comments
 (0)