Skip to content

Commit

Permalink
WFE: Include profile name in returned Order json (#7626)
Browse files Browse the repository at this point in the history
Integration testing revealed that the WFE was not rendering the profile
name in the Order JSON object. Fix the one spot where it was missed.

Part of #7332
  • Loading branch information
aarongable authored Jul 24, 2024
1 parent 6b484f4 commit ff851f7
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion mocks/sa.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ func (sa *StorageAuthorityReadOnly) GetOrder(_ context.Context, req *sapb.OrderR
V2Authorizations: []int64{1},
CertificateSerial: "serial",
Error: nil,
CertificateProfileName: "defaultBoulderCertificateProfile",
CertificateProfileName: "default",
}

// Order ID doesn't have a certificate serial yet
Expand Down
2 changes: 1 addition & 1 deletion test/asserts.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func AssertUnmarshaledEquals(t *testing.T, got, expected string) {
err = json.Unmarshal([]byte(expected), &expectedMap)
AssertNotError(t, err, "Could not unmarshal 'expected'")
if len(gotMap) != len(expectedMap) {
t.Errorf("Expected had %d keys, got had %d", len(gotMap), len(expectedMap))
t.Errorf("Expected %d keys, but got %d", len(expectedMap), len(gotMap))
}
for k, v := range expectedMap {
if !reflect.DeepEqual(v, gotMap[k]) {
Expand Down
3 changes: 2 additions & 1 deletion test/config-next/wfe2.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@
"CheckRenewalExemptionAtWFE": true
},
"certProfiles": {
"defaultBoulderCertificateProfile": "The normal profile you know and love"
"legacy": "The normal profile you know and love",
"modern": "Profile 2: Electric Boogaloo"
}
},
"syslog": {
Expand Down
1 change: 1 addition & 0 deletions wfe2/wfe.go
Original file line number Diff line number Diff line change
Expand Up @@ -1990,6 +1990,7 @@ func (wfe *WebFrontEndImpl) orderToOrderJSON(request *http.Request, order *corep
Expires: order.Expires.AsTime(),
Identifiers: idents,
Finalize: finalizeURL,
Profile: order.CertificateProfileName,
}
// If there is an order error, prefix its type with the V2 namespace
if order.Error != nil {
Expand Down
17 changes: 10 additions & 7 deletions wfe2/wfe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2768,6 +2768,7 @@ func TestFinalizeOrder(t *testing.T) {
"identifiers": [
{"type":"dns","value":"example.com"}
],
"profile": "default",
"authorizations": [
"http://localhost/acme/authz-v3/1"
],
Expand All @@ -2786,8 +2787,7 @@ func TestFinalizeOrder(t *testing.T) {
t.Errorf("Header %q: Expected %q, got %q", k, v, got)
}
}
test.AssertUnmarshaledEquals(t, responseWriter.Body.String(),
tc.ExpectedBody)
test.AssertUnmarshaledEquals(t, responseWriter.Body.String(), tc.ExpectedBody)
})
}

Expand Down Expand Up @@ -2939,7 +2939,7 @@ func TestGetOrder(t *testing.T) {
{
Name: "Good request",
Request: makeGet("1/1"),
Response: `{"status": "valid","expires": "2000-01-01T00:00:00Z","identifiers":[{"type":"dns", "value":"example.com"}], "authorizations":["http://localhost/acme/authz-v3/1"],"finalize":"http://localhost/acme/finalize/1/1","certificate":"http://localhost/acme/cert/serial"}`,
Response: `{"status": "valid","expires": "2000-01-01T00:00:00Z","identifiers":[{"type":"dns", "value":"example.com"}], "profile": "default", "authorizations":["http://localhost/acme/authz-v3/1"],"finalize":"http://localhost/acme/finalize/1/1","certificate":"http://localhost/acme/cert/serial"}`,
},
{
Name: "404 request",
Expand Down Expand Up @@ -2984,7 +2984,7 @@ func TestGetOrder(t *testing.T) {
{
Name: "Valid POST-as-GET",
Request: makePost(1, "1/1", ""),
Response: `{"status": "valid","expires": "2000-01-01T00:00:00Z","identifiers":[{"type":"dns", "value":"example.com"}], "authorizations":["http://localhost/acme/authz-v3/1"],"finalize":"http://localhost/acme/finalize/1/1","certificate":"http://localhost/acme/cert/serial"}`,
Response: `{"status": "valid","expires": "2000-01-01T00:00:00Z","identifiers":[{"type":"dns", "value":"example.com"}], "profile": "default", "authorizations":["http://localhost/acme/authz-v3/1"],"finalize":"http://localhost/acme/finalize/1/1","certificate":"http://localhost/acme/cert/serial"}`,
},
{
Name: "GET new order",
Expand All @@ -2995,17 +2995,17 @@ func TestGetOrder(t *testing.T) {
{
Name: "GET new order from old endpoint",
Request: makeGet("1/9"),
Response: `{"status": "valid","expires": "2000-01-01T00:00:00Z","identifiers":[{"type":"dns", "value":"example.com"}], "authorizations":["http://localhost/acme/authz-v3/1"],"finalize":"http://localhost/acme/finalize/1/9","certificate":"http://localhost/acme/cert/serial"}`,
Response: `{"status": "valid","expires": "2000-01-01T00:00:00Z","identifiers":[{"type":"dns", "value":"example.com"}], "profile": "default", "authorizations":["http://localhost/acme/authz-v3/1"],"finalize":"http://localhost/acme/finalize/1/9","certificate":"http://localhost/acme/cert/serial"}`,
},
{
Name: "POST-as-GET new order",
Request: makePost(1, "1/9", ""),
Response: `{"status": "valid","expires": "2000-01-01T00:00:00Z","identifiers":[{"type":"dns", "value":"example.com"}], "authorizations":["http://localhost/acme/authz-v3/1"],"finalize":"http://localhost/acme/finalize/1/9","certificate":"http://localhost/acme/cert/serial"}`,
Response: `{"status": "valid","expires": "2000-01-01T00:00:00Z","identifiers":[{"type":"dns", "value":"example.com"}], "profile": "default", "authorizations":["http://localhost/acme/authz-v3/1"],"finalize":"http://localhost/acme/finalize/1/9","certificate":"http://localhost/acme/cert/serial"}`,
},
{
Name: "POST-as-GET processing order",
Request: makePost(1, "1/10", ""),
Response: `{"status": "processing","expires": "2000-01-01T00:00:00Z","identifiers":[{"type":"dns", "value":"example.com"}], "authorizations":["http://localhost/acme/authz-v3/1"],"finalize":"http://localhost/acme/finalize/1/10"}`,
Response: `{"status": "processing","expires": "2000-01-01T00:00:00Z","identifiers":[{"type":"dns", "value":"example.com"}], "profile": "default", "authorizations":["http://localhost/acme/authz-v3/1"],"finalize":"http://localhost/acme/finalize/1/10"}`,
Headers: map[string]string{"Retry-After": "3"},
},
}
Expand All @@ -3018,6 +3018,9 @@ func TestGetOrder(t *testing.T) {
} else {
wfe.GetOrder(ctx, newRequestEvent(), responseWriter, tc.Request)
}
t.Log(tc.Name)
t.Log("actual:", responseWriter.Body.String())
t.Log("expect:", tc.Response)
test.AssertUnmarshaledEquals(t, responseWriter.Body.String(), tc.Response)
for k, v := range tc.Headers {
test.AssertEquals(t, responseWriter.Header().Get(k), v)
Expand Down

0 comments on commit ff851f7

Please sign in to comment.