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).
This commit is contained in:
Jacob Hoffman-Andrews 2019-01-17 06:45:56 -08:00 committed by Daniel McCarney
parent 413028aa1b
commit bf7f638a25
2 changed files with 13 additions and 0 deletions

View File

@ -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))

View File

@ -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) {