Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions sa/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -1173,6 +1173,10 @@ func getAuthorizationStatuses(ctx context.Context, s db.Selector, ids []int64) (
return nil, err
}

if len(validities) != len(ids) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this check in place, this method no longer tolerates duplicate ids. We don't necessarily expect duplicate ids, but previously they would not have errored. We should stipulate this requirement in the doc comment.

return nil, fmt.Errorf("getAuthorizationStatuses got %d results, expected %d", len(validities), len(ids))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could provide a bit more context here.

Suggested change
return nil, fmt.Errorf("getAuthorizationStatuses got %d results, expected %d", len(validities), len(ids))
return nil, fmt.Errorf("getAuthorizationStatuses got %d results, expected %d for ids %v", len(validities), len(ids), ids)

}

return validities, nil
}

Expand Down
16 changes: 12 additions & 4 deletions sa/sa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2687,10 +2687,18 @@ func TestGetOrderExpired(t *testing.T) {
reg := createWorkingRegistration(t, sa)
order, err := sa.NewOrderAndAuthzs(context.Background(), &sapb.NewOrderAndAuthzsRequest{
NewOrder: &sapb.NewOrderRequest{
RegistrationID: reg.Id,
Expires: timestamppb.New(now.Add(-time.Hour)),
Identifiers: []*corepb.Identifier{identifier.NewDNS("example.com").ToProto()},
V2Authorizations: []int64{666},
RegistrationID: reg.Id,
Expires: timestamppb.New(now.Add(-time.Hour)),
Identifiers: []*corepb.Identifier{identifier.NewDNS("example.com").ToProto()},
},
NewAuthzs: []*sapb.NewAuthzRequest{
{
Identifier: &corepb.Identifier{Type: "dns", Value: "example.com"},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could use the same identifier.NewDNS("example.com").ToProto() as used above, here.

RegistrationID: reg.Id,
Expires: timestamppb.New(now.Add(time.Hour)),
ChallengeTypes: []string{string(core.ChallengeTypeHTTP01)},
Token: core.NewToken(),
},
},
})
test.AssertNotError(t, err, "NewOrderAndAuthzs failed")
Expand Down
Loading