From bf7f638a25cdf5f9d1aa8a3ef0c55b90731ad96d Mon Sep 17 00:00:00 2001 From: Jacob Hoffman-Andrews Date: Thu, 17 Jan 2019 06:45:56 -0800 Subject: [PATCH] Set "Created" field for new-order. (#4013) This will allow us to connect new-order requests with the order URLs that are created as a result. Also ensure the Requester is filled in for new-acct requests that return an existing account (it's already filled in for new-acct requests that create an account). --- wfe2/wfe.go | 2 ++ wfe2/wfe_test.go | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/wfe2/wfe.go b/wfe2/wfe.go index 72a7611d7..fa0593a40 100644 --- a/wfe2/wfe.go +++ b/wfe2/wfe.go @@ -485,6 +485,7 @@ func (wfe *WebFrontEndImpl) NewAccount( if err == nil { response.Header().Set("Location", web.RelativeEndpoint(request, fmt.Sprintf("%s%d", acctPath, existingAcct.ID))) + logEvent.Requester = existingAcct.ID err = wfe.writeJsonResponse(response, logEvent, http.StatusOK, existingAcct) if err != nil { @@ -1675,6 +1676,7 @@ func (wfe *WebFrontEndImpl) NewOrder( wfe.sendError(response, logEvent, web.ProblemDetailsForError(err, "Error creating new order"), err) return } + logEvent.Created = fmt.Sprintf("%d", *order.Id) orderURL := web.RelativeEndpoint(request, fmt.Sprintf("%s%d/%d", orderPath, acct.ID, *order.Id)) diff --git a/wfe2/wfe_test.go b/wfe2/wfe_test.go index 6f9aee90e..eea5951d5 100644 --- a/wfe2/wfe_test.go +++ b/wfe2/wfe_test.go @@ -2072,6 +2072,17 @@ func TestNewOrder(t *testing.T) { } }) } + + // Test that we log the "Created" field. + responseWriter.Body.Reset() + responseWriter.HeaderMap = http.Header{} + request := signAndPost(t, targetPath, signedURL, validOrderBody, 1, wfe.nonceService) + requestEvent := newRequestEvent() + wfe.NewOrder(ctx, requestEvent, responseWriter, request) + + if requestEvent.Created != "1" { + t.Errorf("Expected to log Created field when creating Order: %#v", requestEvent) + } } func TestFinalizeOrder(t *testing.T) {