From 4df94d5215d00d703d55f4b2f0b61a18faa9986c Mon Sep 17 00:00:00 2001 From: Jacob Hoffman-Andrews Date: Wed, 8 Apr 2020 17:21:50 -0700 Subject: [PATCH] Use responseWriter.Body.Bytes() (#4759) staticcheck cleanup: https://staticcheck.io/docs/checks#S1030 --- wfe/wfe_test.go | 12 ++++++------ wfe2/wfe_test.go | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/wfe/wfe_test.go b/wfe/wfe_test.go index 3f4368ebc..6cd24b116 100644 --- a/wfe/wfe_test.go +++ b/wfe/wfe_test.go @@ -1272,7 +1272,7 @@ func TestNewECDSARegistration(t *testing.T) { wfe.NewRegistration(ctx, newRequestEvent(), responseWriter, makePostRequest(result.FullSerialize())) var reg core.Registration - err = json.Unmarshal([]byte(responseWriter.Body.String()), ®) + err = json.Unmarshal(responseWriter.Body.Bytes(), ®) test.AssertNotError(t, err, "Couldn't unmarshal returned registration object") test.Assert(t, len(*reg.Contact) >= 1, "No contact field in registration") test.AssertEquals(t, (*reg.Contact)[0], "mailto:person@mail.com") @@ -1331,7 +1331,7 @@ func TestEmptyRegistration(t *testing.T) { // We should get back a populated Registration var reg core.Registration - err = json.Unmarshal([]byte(responseWriter.Body.String()), ®) + err = json.Unmarshal(responseWriter.Body.Bytes(), ®) test.AssertNotError(t, err, "Couldn't unmarshal returned registration object") test.Assert(t, len(*reg.Contact) >= 1, "No contact field in registration") test.AssertEquals(t, (*reg.Contact)[0], "mailto:person@mail.com") @@ -1466,7 +1466,7 @@ func TestNewRegistration(t *testing.T) { makePostRequest(result.FullSerialize())) var reg core.Registration - err = json.Unmarshal([]byte(responseWriter.Body.String()), ®) + err = json.Unmarshal(responseWriter.Body.Bytes(), ®) test.AssertNotError(t, err, "Couldn't unmarshal returned registration object") test.Assert(t, len(*reg.Contact) >= 1, "No contact field in registration") test.AssertEquals(t, (*reg.Contact)[0], "mailto:person@mail.com") @@ -1856,7 +1856,7 @@ func TestAuthorization(t *testing.T) { test.AssertUnmarshaledEquals(t, responseWriter.Body.String(), `{"identifier":{"type":"dns","value":"test.com"}}`) var authz core.Authorization - err := json.Unmarshal([]byte(responseWriter.Body.String()), &authz) + err := json.Unmarshal(responseWriter.Body.Bytes(), &authz) test.AssertNotError(t, err, "Couldn't unmarshal returned authorization object") // Expired authorizations should be inaccessible @@ -1942,7 +1942,7 @@ func TestAuthorizationChallengeNamespace(t *testing.T) { }) var authz core.Authorization - err := json.Unmarshal([]byte(responseWriter.Body.String()), &authz) + err := json.Unmarshal(responseWriter.Body.Bytes(), &authz) test.AssertNotError(t, err, "Couldn't unmarshal returned authorization object") test.AssertEquals(t, len(authz.Challenges), 1) // The Challenge Error Type should have its prefix unmodified @@ -1957,7 +1957,7 @@ func TestAuthorizationChallengeNamespace(t *testing.T) { URL: mustParseURL(authzURL), }) - err = json.Unmarshal([]byte(responseWriter.Body.String()), &authz) + err = json.Unmarshal(responseWriter.Body.Bytes(), &authz) test.AssertNotError(t, err, "Couldn't unmarshal returned authorization object") test.AssertEquals(t, len(authz.Challenges), 1) // The Challenge Error Type should have had the probs.V1ErrorNS prefix added diff --git a/wfe2/wfe_test.go b/wfe2/wfe_test.go index 12c760e47..0fcd0152f 100644 --- a/wfe2/wfe_test.go +++ b/wfe2/wfe_test.go @@ -1618,7 +1618,7 @@ func TestAuthorizationChallengeNamespace(t *testing.T) { }) var authz core.Authorization - err := json.Unmarshal([]byte(responseWriter.Body.String()), &authz) + err := json.Unmarshal(responseWriter.Body.Bytes(), &authz) test.AssertNotError(t, err, "Couldn't unmarshal returned authorization object") test.AssertEquals(t, len(authz.Challenges), 1) // The Challenge Error Type should have its prefix unmodified @@ -1632,7 +1632,7 @@ func TestAuthorizationChallengeNamespace(t *testing.T) { URL: mustParseURL("56"), }) - err = json.Unmarshal([]byte(responseWriter.Body.String()), &authz) + err = json.Unmarshal(responseWriter.Body.Bytes(), &authz) test.AssertNotError(t, err, "Couldn't unmarshal returned authorization object") test.AssertEquals(t, len(authz.Challenges), 1) // The Challenge Error Type should have had the probs.V2ErrorNS prefix added