@@ -1005,6 +1005,33 @@ func TestNewOrderAndAuthzs(t *testing.T) {
10051005 test .Assert (t , newAuthzIDs [0 ] != newAuthzIDs [1 ], "expected distinct new authz IDs" )
10061006}
10071007
1008+ func TestNewOrderAndAuthzsRejectsDuplicates (t * testing.T ) {
1009+ sa , fc := initSA (t )
1010+
1011+ reg := createWorkingRegistration (t , sa )
1012+
1013+ idA := createPendingAuthorization (t , sa , reg .Id , identifier .NewDNS ("a.com" ), sa .clk .Now ().Add (time .Hour ))
1014+ _ , err := sa .NewOrderAndAuthzs (context .Background (), & sapb.NewOrderAndAuthzsRequest {
1015+ NewOrder : & sapb.NewOrderRequest {
1016+ RegistrationID : reg .Id ,
1017+ Expires : timestamppb .New (fc .Now ().Add (2 * time .Hour )),
1018+ Identifiers : []* corepb.Identifier {
1019+ identifier .NewDNS ("a.com" ).ToProto (),
1020+ identifier .NewDNS ("b.com" ).ToProto (),
1021+ },
1022+ V2Authorizations : []int64 {idA , idA },
1023+ },
1024+ })
1025+
1026+ if err == nil {
1027+ t .Fatal ("sa.NewOrderAndAuthzs with duplicate authorizations: got nil error, want error" )
1028+ }
1029+ expected := "cannot add duplicate authorizations to order"
1030+ if err .Error () != expected {
1031+ t .Errorf ("sa.NewOrderAndAuthzs with duplicate authorizations: got error %q, want error %q" , err , expected )
1032+ }
1033+ }
1034+
10081035func TestNewOrderAndAuthzs_ReuseOnly (t * testing.T ) {
10091036 sa , fc := initSA (t )
10101037
@@ -2685,12 +2712,21 @@ func TestGetOrderExpired(t *testing.T) {
26852712 fc .Add (time .Hour * 5 )
26862713 now := fc .Now ()
26872714 reg := createWorkingRegistration (t , sa )
2715+ exampleDotCom := identifier .NewDNS ("example.com" ).ToProto ()
26882716 order , err := sa .NewOrderAndAuthzs (context .Background (), & sapb.NewOrderAndAuthzsRequest {
26892717 NewOrder : & sapb.NewOrderRequest {
2690- RegistrationID : reg .Id ,
2691- Expires : timestamppb .New (now .Add (- time .Hour )),
2692- Identifiers : []* corepb.Identifier {identifier .NewDNS ("example.com" ).ToProto ()},
2693- V2Authorizations : []int64 {666 },
2718+ RegistrationID : reg .Id ,
2719+ Expires : timestamppb .New (now .Add (- time .Hour )),
2720+ Identifiers : []* corepb.Identifier {exampleDotCom },
2721+ },
2722+ NewAuthzs : []* sapb.NewAuthzRequest {
2723+ {
2724+ Identifier : exampleDotCom ,
2725+ RegistrationID : reg .Id ,
2726+ Expires : timestamppb .New (now .Add (time .Hour )),
2727+ ChallengeTypes : []string {string (core .ChallengeTypeHTTP01 )},
2728+ Token : core .NewToken (),
2729+ },
26942730 },
26952731 })
26962732 test .AssertNotError (t , err , "NewOrderAndAuthzs failed" )
0 commit comments