Skip to content

Commit cc66969

Browse files
authored
Remove nearly-unused WrongAuthorizationState error (letsencrypt#5176)
This error class is only used in one instance, and when returned to the user it is transformed into a `probs.Malformed` anyway. It does more harm than good to keep this one-off BoulderError around, as it introduces confusion about what sorts of errors we expose to the client. Fixes letsencrypt#5167
1 parent 2f86884 commit cc66969

File tree

4 files changed

+5
-12
lines changed

4 files changed

+5
-12
lines changed

errors/errors.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const (
2222
RejectedIdentifier
2323
InvalidEmail
2424
ConnectionFailure
25-
WrongAuthorizationState
25+
_ // Reserved, previously WrongAuthorizationState
2626
CAA
2727
MissingSCTs
2828
Duplicate
@@ -111,10 +111,6 @@ func ConnectionFailureError(msg string, args ...interface{}) error {
111111
return New(ConnectionFailure, msg, args...)
112112
}
113113

114-
func WrongAuthorizationStateError(msg string, args ...interface{}) error {
115-
return New(WrongAuthorizationState, msg, args...)
116-
}
117-
118114
func CAAError(msg string, args ...interface{}) error {
119115
return New(CAA, msg, args...)
120116
}

ra/ra.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,17 +1532,16 @@ func (ra *RegistrationAuthorityImpl) recordValidation(ctx context.Context, authI
15321532
func (ra *RegistrationAuthorityImpl) PerformValidation(
15331533
ctx context.Context,
15341534
req *rapb.PerformValidationRequest) (*corepb.Authorization, error) {
1535-
base, err := bgrpc.PBToAuthz(req.Authz)
1535+
authz, err := bgrpc.PBToAuthz(req.Authz)
15361536
if err != nil {
15371537
return nil, err
15381538
}
15391539

15401540
// Refuse to update expired authorizations
1541-
if base.Expires == nil || base.Expires.Before(ra.clk.Now()) {
1541+
if authz.Expires == nil || authz.Expires.Before(ra.clk.Now()) {
15421542
return nil, berrors.MalformedError("expired authorization")
15431543
}
15441544

1545-
authz := base
15461545
challIndex := int(req.ChallengeIndex)
15471546
if challIndex >= len(authz.Challenges) {
15481547
return nil,
@@ -1566,7 +1565,7 @@ func (ra *RegistrationAuthorityImpl) PerformValidation(
15661565
}
15671566

15681567
if authz.Status != core.StatusPending {
1569-
return nil, berrors.WrongAuthorizationStateError("authorization must be pending")
1568+
return nil, berrors.MalformedError("authorization must be pending")
15701569
}
15711570

15721571
// Look up the account key for this authorization

ra/ra_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ func TestPerformValidationAlreadyValid(t *testing.T) {
920920
Authz: authzPB,
921921
ChallengeIndex: int64(ResponseIndex),
922922
})
923-
test.AssertErrorIs(t, err, berrors.WrongAuthorizationState)
923+
test.AssertErrorIs(t, err, berrors.Malformed)
924924
}
925925

926926
func TestPerformValidationSuccess(t *testing.T) {

web/probs.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ func problemDetailsForBoulderError(err *berrors.BoulderError, msg string) *probs
2828
outProb = probs.RejectedIdentifier(fmt.Sprintf("%s :: %s", msg, err))
2929
case berrors.InvalidEmail:
3030
outProb = probs.InvalidEmail(fmt.Sprintf("%s :: %s", msg, err))
31-
case berrors.WrongAuthorizationState:
32-
outProb = probs.Malformed(fmt.Sprintf("%s :: %s", msg, err))
3331
case berrors.CAA:
3432
outProb = probs.CAA(fmt.Sprintf("%s :: %s", msg, err))
3533
case berrors.MissingSCTs:

0 commit comments

Comments
 (0)