Skip to content

Commit

Permalink
Adjust when we return the field.
Browse files Browse the repository at this point in the history
  • Loading branch information
beautifulentropy committed Mar 12, 2024
1 parent 115b43b commit 346a37e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
18 changes: 5 additions & 13 deletions wfe2/wfe.go
Original file line number Diff line number Diff line change
Expand Up @@ -2006,8 +2006,8 @@ type orderJSON struct {
Expires time.Time `json:"expires"`
Identifiers []identifier.ACMEIdentifier `json:"identifiers"`
Authorizations []string `json:"authorizations"`
Profile string `json:"profile,omitempty"`
Finalize string `json:"finalize"`
Profile string `json:"profile,omitempty"`
Certificate string `json:"certificate,omitempty"`
Error *probs.ProblemDetails `json:"error,omitempty"`
}
Expand All @@ -2016,7 +2016,7 @@ type orderJSON struct {
// that is returned in HTTP API responses. It will convert the order names to
// DNS type identifiers and additionally create absolute URLs for the finalize
// URL and the ceritificate URL as appropriate.
func (wfe *WebFrontEndImpl) orderToOrderJSON(request *http.Request, order *corepb.Order, includProfile bool) orderJSON {
func (wfe *WebFrontEndImpl) orderToOrderJSON(request *http.Request, order *corepb.Order) orderJSON {
idents := make([]identifier.ACMEIdentifier, len(order.Names))
for i, name := range order.Names {
idents[i] = identifier.ACMEIdentifier{Type: identifier.DNS, Value: name}
Expand All @@ -2029,9 +2029,6 @@ func (wfe *WebFrontEndImpl) orderToOrderJSON(request *http.Request, order *corep
Identifiers: idents,
Finalize: finalizeURL,
}
if includProfile {
respObj.Profile = order.CertificateProfileName
}

// If there is an order error, prefix its type with the V2 namespace
if order.Error != nil {
Expand Down Expand Up @@ -2400,12 +2397,7 @@ func (wfe *WebFrontEndImpl) NewOrder(
fmt.Sprintf("%s%d/%d", orderPath, acct.ID, order.Id))
response.Header().Set("Location", orderURL)

var respondWithProfile bool
if newOrderRequest.Profile != "" {
respondWithProfile = true
}

respObj := wfe.orderToOrderJSON(request, order, respondWithProfile)
respObj := wfe.orderToOrderJSON(request, order)
err = wfe.writeJsonResponse(response, logEvent, http.StatusCreated, respObj)
if err != nil {
wfe.sendError(response, logEvent, probs.ServerInternal("Error marshaling order"), err)
Expand Down Expand Up @@ -2482,7 +2474,7 @@ func (wfe *WebFrontEndImpl) GetOrder(ctx context.Context, logEvent *web.RequestE
return
}

respObj := wfe.orderToOrderJSON(request, order, false)
respObj := wfe.orderToOrderJSON(request, order)

if respObj.Status == core.StatusProcessing {
response.Header().Set(headerRetryAfter, strconv.Itoa(orderRetryAfter))
Expand Down Expand Up @@ -2612,7 +2604,7 @@ func (wfe *WebFrontEndImpl) FinalizeOrder(ctx context.Context, logEvent *web.Req
fmt.Sprintf("%s%d/%d", orderPath, acct.ID, updatedOrder.Id))
response.Header().Set("Location", orderURL)

respObj := wfe.orderToOrderJSON(request, updatedOrder, false)
respObj := wfe.orderToOrderJSON(request, updatedOrder)

if respObj.Status == core.StatusProcessing {
response.Header().Set(headerRetryAfter, strconv.Itoa(orderRetryAfter))
Expand Down
2 changes: 1 addition & 1 deletion wfe2/wfe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3398,7 +3398,7 @@ func TestOrderToOrderJSONV2Authorizations(t *testing.T) {
Status: string(core.StatusPending),
Expires: timestamppb.New(expires),
V2Authorizations: []int64{1, 2},
}, false)
})
test.AssertDeepEquals(t, orderJSON.Authorizations, []string{
"http://localhost/acme/authz-v3/1",
"http://localhost/acme/authz-v3/2",
Expand Down

0 comments on commit 346a37e

Please sign in to comment.