diff --git a/auth/auth_test.go b/auth/auth_test.go index 69127b22..53daf79f 100644 --- a/auth/auth_test.go +++ b/auth/auth_test.go @@ -19,7 +19,6 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" "log" "net/http" "os" @@ -74,10 +73,10 @@ func TestMain(m *testing.M) { testCookieVerifier, err = cookieVerifierForTests(context.Background()) logFatal(err) - testGetUserResponse, err = ioutil.ReadFile("../testdata/get_user.json") + testGetUserResponse, err = os.ReadFile("../testdata/get_user.json") logFatal(err) - testGetDisabledUserResponse, err = ioutil.ReadFile("../testdata/get_disabled_user.json") + testGetDisabledUserResponse, err = os.ReadFile("../testdata/get_disabled_user.json") logFatal(err) testIDToken = getIDToken(nil) @@ -1290,7 +1289,7 @@ type mockKeySource struct { } func newMockKeySource(filePath string) (*mockKeySource, error) { - certs, err := ioutil.ReadFile(filePath) + certs, err := os.ReadFile(filePath) if err != nil { return nil, err } diff --git a/auth/tenant_mgt_test.go b/auth/tenant_mgt_test.go index aaf65b52..574c91f1 100644 --- a/auth/tenant_mgt_test.go +++ b/auth/tenant_mgt_test.go @@ -18,8 +18,8 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" "net/http" + "os" "reflect" "sort" "strconv" @@ -178,7 +178,7 @@ func TestTenantGetUserByPhoneNumber(t *testing.T) { } func TestTenantListUsers(t *testing.T) { - testListUsersResponse, err := ioutil.ReadFile("../testdata/list_users.json") + testListUsersResponse, err := os.ReadFile("../testdata/list_users.json") if err != nil { t.Fatal(err) } diff --git a/auth/token_generator_test.go b/auth/token_generator_test.go index 6ed5144e..0aaf7f3c 100644 --- a/auth/token_generator_test.go +++ b/auth/token_generator_test.go @@ -20,9 +20,10 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "net/http" "net/http/httptest" + "os" "strings" "testing" @@ -90,7 +91,7 @@ func TestEncodeInvalidPayload(t *testing.T) { } func TestServiceAccountSigner(t *testing.T) { - b, err := ioutil.ReadFile("../testdata/service_account.json") + b, err := os.ReadFile("../testdata/service_account.json") if err != nil { t.Fatal(err) } @@ -331,7 +332,7 @@ func iamServer(t *testing.T, serviceAcct, signature string) *httptest.Server { wantPath := fmt.Sprintf("/v1/projects/-/serviceAccounts/%s:signBlob", serviceAcct) handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { defer r.Body.Close() - reqBody, err := ioutil.ReadAll(r.Body) + reqBody, err := io.ReadAll(r.Body) if err != nil { t.Fatal(err) } diff --git a/auth/token_verifier.go b/auth/token_verifier.go index fe6cdf0c..8ab81da3 100644 --- a/auth/token_verifier.go +++ b/auth/token_verifier.go @@ -26,7 +26,7 @@ import ( "encoding/pem" "errors" "fmt" - "io/ioutil" + "io" "net/http" "strconv" "strings" @@ -417,7 +417,7 @@ func (k *httpKeySource) refreshKeys(ctx context.Context) error { } defer resp.Body.Close() - contents, err := ioutil.ReadAll(resp.Body) + contents, err := io.ReadAll(resp.Body) if err != nil { return err } diff --git a/auth/token_verifier_test.go b/auth/token_verifier_test.go index e24d7d1c..3a560651 100644 --- a/auth/token_verifier_test.go +++ b/auth/token_verifier_test.go @@ -19,8 +19,8 @@ import ( "errors" "fmt" "io" - "io/ioutil" "net/http" + "os" "testing" "time" @@ -51,7 +51,7 @@ func TestNewIDTokenVerifier(t *testing.T) { } func TestHTTPKeySource(t *testing.T) { - data, err := ioutil.ReadFile("../testdata/public_certs.json") + data, err := os.ReadFile("../testdata/public_certs.json") if err != nil { t.Fatal(err) } @@ -68,7 +68,7 @@ func TestHTTPKeySource(t *testing.T) { } func TestHTTPKeySourceWithClient(t *testing.T) { - data, err := ioutil.ReadFile("../testdata/public_certs.json") + data, err := os.ReadFile("../testdata/public_certs.json") if err != nil { t.Fatal(err) } @@ -160,7 +160,7 @@ func TestFindMaxAge(t *testing.T) { } func TestParsePublicKeys(t *testing.T) { - b, err := ioutil.ReadFile("../testdata/public_certs.json") + b, err := os.ReadFile("../testdata/public_certs.json") if err != nil { t.Fatal(err) } diff --git a/auth/user_mgt_test.go b/auth/user_mgt_test.go index 094716c2..6464fc53 100644 --- a/auth/user_mgt_test.go +++ b/auth/user_mgt_test.go @@ -20,9 +20,10 @@ import ( "encoding/base64" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "net/http/httptest" + "os" "reflect" "sort" "strconv" @@ -545,7 +546,7 @@ func TestGetNonExistingUser(t *testing.T) { } func TestListUsers(t *testing.T) { - testListUsersResponse, err := ioutil.ReadFile("../testdata/list_users.json") + testListUsersResponse, err := os.ReadFile("../testdata/list_users.json") if err != nil { t.Fatal(err) } @@ -2542,7 +2543,7 @@ func echoServer(resp interface{}, t *testing.T) *mockAuthServer { handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { defer r.Body.Close() - reqBody, err := ioutil.ReadAll(r.Body) + reqBody, err := io.ReadAll(r.Body) if err != nil { t.Fatal(err) } diff --git a/db/db_test.go b/db/db_test.go index 68517189..35192d0e 100644 --- a/db/db_test.go +++ b/db/db_test.go @@ -18,7 +18,7 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" + "io" "log" "net/http" "net/http/httptest" @@ -395,7 +395,7 @@ type testReq struct { func newTestReq(r *http.Request) (*testReq, error) { defer r.Body.Close() - b, err := ioutil.ReadAll(r.Body) + b, err := io.ReadAll(r.Body) if err != nil { return nil, err } diff --git a/firebase.go b/firebase.go index 39d1c4e2..d974d4b2 100644 --- a/firebase.go +++ b/firebase.go @@ -21,7 +21,6 @@ import ( "context" "encoding/json" "errors" - "io/ioutil" "os" "sync" @@ -231,7 +230,7 @@ func getConfigDefaults() (*Config, error) { dat = []byte(confFileName) } else { var err error - if dat, err = ioutil.ReadFile(confFileName); err != nil { + if dat, err = os.ReadFile(confFileName); err != nil { return nil, err } } diff --git a/firebase_test.go b/firebase_test.go index 789ea188..25ec1b88 100644 --- a/firebase_test.go +++ b/firebase_test.go @@ -18,7 +18,6 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" "log" "net/http" "net/http/httptest" @@ -688,7 +687,7 @@ func compareConfig(got *App, want *Config, t *testing.T) { // mockServiceAcct generates a service account configuration with the provided URL as the // token_url value. func mockServiceAcct(tokenURL string) ([]byte, error) { - b, err := ioutil.ReadFile("testdata/service_account.json") + b, err := os.ReadFile("testdata/service_account.json") if err != nil { return nil, err } diff --git a/integration/auth/auth_test.go b/integration/auth/auth_test.go index 3bf43461..641cdbab 100644 --- a/integration/auth/auth_test.go +++ b/integration/auth/auth_test.go @@ -24,7 +24,7 @@ import ( "encoding/json" "flag" "fmt" - "io/ioutil" + "io" "log" "math/rand" "net/http" @@ -86,7 +86,7 @@ func TestCustomToken(t *testing.T) { func TestCustomTokenWithoutServiceAccount(t *testing.T) { // Create a TokenSource from the service account. This makes the private key not accessible // to the Firebase APIs. - b, err := ioutil.ReadFile(internal.Resource("integration_cert.json")) + b, err := os.ReadFile(internal.Resource("integration_cert.json")) if err != nil { t.Fatal(err) } @@ -382,7 +382,7 @@ func postRequest(url string, req []byte) ([]byte, error) { if resp.StatusCode != http.StatusOK { return nil, fmt.Errorf("unexpected http status code: %d", resp.StatusCode) } - return ioutil.ReadAll(resp.Body) + return io.ReadAll(resp.Body) } // deleteUser makes a best effort attempt to delete the given user. diff --git a/integration/db/db_test.go b/integration/db/db_test.go index 9a5d715a..32c64b45 100644 --- a/integration/db/db_test.go +++ b/integration/db/db_test.go @@ -21,7 +21,7 @@ import ( "encoding/json" "flag" "fmt" - "io/ioutil" + "io" "log" "net/http" "os" @@ -137,7 +137,7 @@ func initGuestClient(pid string) (*db.Client, error) { } func initRules() { - b, err := ioutil.ReadFile(internal.Resource("dinosaurs_index.json")) + b, err := os.ReadFile(internal.Resource("dinosaurs_index.json")) if err != nil { log.Fatalln(err) } @@ -162,7 +162,7 @@ func initRules() { } defer resp.Body.Close() - b, err = ioutil.ReadAll(resp.Body) + b, err = io.ReadAll(resp.Body) if err != nil { log.Fatalln(err) } else if resp.StatusCode != http.StatusOK { @@ -171,7 +171,7 @@ func initRules() { } func initData() { - b, err := ioutil.ReadFile(internal.Resource("dinosaurs.json")) + b, err := os.ReadFile(internal.Resource("dinosaurs.json")) if err != nil { log.Fatalln(err) } diff --git a/integration/internal/internal.go b/integration/internal/internal.go index d57b3f91..828f803e 100644 --- a/integration/internal/internal.go +++ b/integration/internal/internal.go @@ -18,8 +18,8 @@ package internal import ( "context" "encoding/json" - "io/ioutil" "net/http" + "os" "path/filepath" "strings" @@ -52,7 +52,7 @@ func NewTestApp(ctx context.Context, conf *firebase.Config) (*firebase.App, erro // APIKey reads the API key string from a file named integration_apikey.txt // in the testdata directory. func APIKey() (string, error) { - b, err := ioutil.ReadFile(Resource(apiKeyPath)) + b, err := os.ReadFile(Resource(apiKeyPath)) if err != nil { return "", err } @@ -61,7 +61,7 @@ func APIKey() (string, error) { // ProjectID fetches a Google Cloud project ID for integration tests. func ProjectID() (string, error) { - b, err := ioutil.ReadFile(Resource(certPath)) + b, err := os.ReadFile(Resource(certPath)) if err != nil { return "", err } diff --git a/integration/storage/storage_test.go b/integration/storage/storage_test.go index 860288bc..d641bb97 100644 --- a/integration/storage/storage_test.go +++ b/integration/storage/storage_test.go @@ -18,7 +18,7 @@ import ( "context" "flag" "fmt" - "io/ioutil" + "io" "log" "os" "testing" @@ -115,7 +115,7 @@ func verifyBucket(bucket *gcs.BucketHandle) error { return err } defer r.Close() - b, err := ioutil.ReadAll(r) + b, err := io.ReadAll(r) if err != nil { return err } diff --git a/internal/errors_test.go b/internal/errors_test.go index ccd38f20..d4c41612 100644 --- a/internal/errors_test.go +++ b/internal/errors_test.go @@ -19,7 +19,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "net" "net/http" "net/http/httptest" @@ -321,7 +321,7 @@ func TestErrorHTTPResponse(t *testing.T) { t.Errorf("Do() Response.StatusCode = %d; want = %d", hr.StatusCode, http.StatusInternalServerError) } - b, err := ioutil.ReadAll(hr.Body) + b, err := io.ReadAll(hr.Body) if err != nil { t.Fatalf("ReadAll(Response.Body) = %v", err) } diff --git a/internal/http_client.go b/internal/http_client.go index 9d1257bc..6f70d753 100644 --- a/internal/http_client.go +++ b/internal/http_client.go @@ -20,7 +20,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "math" "net/http" "runtime" @@ -121,7 +120,7 @@ func (r *Response) LowLevelResponse() *http.Response { } resp := *r.resp - resp.Body = ioutil.NopCloser(bytes.NewBuffer(r.Body)) + resp.Body = io.NopCloser(bytes.NewBuffer(r.Body)) return &resp } @@ -305,7 +304,7 @@ func (e *jsonEntity) Mime() string { func newResponse(resp *http.Response) (*Response, error) { defer resp.Body.Close() - b, err := ioutil.ReadAll(resp.Body) + b, err := io.ReadAll(resp.Body) if err != nil { return nil, err } diff --git a/internal/http_client_test.go b/internal/http_client_test.go index 22b498cf..03dccabc 100644 --- a/internal/http_client_test.go +++ b/internal/http_client_test.go @@ -18,7 +18,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "net/http" "net/http/httptest" "reflect" @@ -147,7 +147,7 @@ func TestHTTPClient(t *testing.T) { t.Errorf("[%d] Content-Type = %q; want = %q", idx, h, "application/json") } wb := []byte(want.body) - gb, err := ioutil.ReadAll(r.Body) + gb, err := io.ReadAll(r.Body) if err != nil { t.Fatal(err) } diff --git a/internal/json_http_client_test.go b/internal/json_http_client_test.go index be827b75..06a503f4 100644 --- a/internal/json_http_client_test.go +++ b/internal/json_http_client_test.go @@ -18,7 +18,7 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "net/http/httptest" "strings" @@ -72,7 +72,7 @@ func TestDoAndUnmarshalPost(t *testing.T) { var b []byte handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { req = r - b, _ = ioutil.ReadAll(r.Body) + b, _ = io.ReadAll(r.Body) resp := `{ "name": "test" }` diff --git a/messaging/messaging_batch.go b/messaging/messaging_batch.go index 7dc6c110..dcf3af9c 100644 --- a/messaging/messaging_batch.go +++ b/messaging/messaging_batch.go @@ -22,7 +22,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "mime" "mime/multipart" "net/http" @@ -466,7 +465,7 @@ func newSendResponse(part *multipart.Part) (*SendResponse, error) { return nil, fmt.Errorf("error parsing multipart body: %v", err) } - b, err := ioutil.ReadAll(hr.Body) + b, err := io.ReadAll(hr.Body) if err != nil { return nil, err } diff --git a/messaging/messaging_batch_test.go b/messaging/messaging_batch_test.go index 25ac5a11..f0099d49 100644 --- a/messaging/messaging_batch_test.go +++ b/messaging/messaging_batch_test.go @@ -21,7 +21,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "mime/multipart" "net/http" "net/http/httptest" @@ -474,7 +473,7 @@ func TestSendEachInvalidMessage(t *testing.T) { func TestSendEach(t *testing.T) { ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - req, _ := ioutil.ReadAll(r.Body) + req, _ := io.ReadAll(r.Body) w.Header().Set("Content-Type", "application/json") for idx, testMessage := range testMessages { if strings.Contains(string(req), testMessage.Topic) { @@ -502,7 +501,7 @@ func TestSendEach(t *testing.T) { func TestSendEachDryRun(t *testing.T) { ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - req, _ := ioutil.ReadAll(r.Body) + req, _ := io.ReadAll(r.Body) w.Header().Set("Content-Type", "application/json") for idx, testMessage := range testMessages { if strings.Contains(string(req), testMessage.Topic) { @@ -548,7 +547,7 @@ func TestSendEachPartialFailure(t *testing.T) { mu.Lock() serverHitCount++ mu.Unlock() - reqBody, _ := ioutil.ReadAll(r.Body) + reqBody, _ := io.ReadAll(r.Body) var msgIn fcmRequest json.Unmarshal(reqBody, &msgIn) @@ -739,7 +738,7 @@ func TestSendEachForMulticastInvalidMessage(t *testing.T) { func TestSendEachForMulticast(t *testing.T) { ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - req, _ := ioutil.ReadAll(r.Body) + req, _ := io.ReadAll(r.Body) w.Header().Set("Content-Type", "application/json") for idx, token := range testMulticastMessage.Tokens { if strings.Contains(string(req), token) { @@ -767,7 +766,7 @@ func TestSendEachForMulticast(t *testing.T) { func TestSendEachForMulticastFids(t *testing.T) { ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - req, _ := ioutil.ReadAll(r.Body) + req, _ := io.ReadAll(r.Body) w.Header().Set("Content-Type", "application/json") for idx, fid := range testFidMulticastMessage.Fids { if strings.Contains(string(req), fid) { @@ -795,7 +794,7 @@ func TestSendEachForMulticastFids(t *testing.T) { func TestSendEachForMulticastMixed(t *testing.T) { ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - req, _ := ioutil.ReadAll(r.Body) + req, _ := io.ReadAll(r.Body) w.Header().Set("Content-Type", "application/json") for idx, token := range testMixedMulticastMessage.Tokens { if strings.Contains(string(req), token) { @@ -828,7 +827,7 @@ func TestSendEachForMulticastMixed(t *testing.T) { func TestSendEachForMulticastWithCustomEndpoint(t *testing.T) { ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - req, _ := ioutil.ReadAll(r.Body) + req, _ := io.ReadAll(r.Body) w.Header().Set("Content-Type", "application/json") for idx, token := range testMulticastMessage.Tokens { if strings.Contains(string(req), token) { @@ -861,7 +860,7 @@ func TestSendEachForMulticastWithCustomEndpoint(t *testing.T) { func TestSendEachForMulticastDryRun(t *testing.T) { ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - req, _ := ioutil.ReadAll(r.Body) + req, _ := io.ReadAll(r.Body) w.Header().Set("Content-Type", "application/json") for idx, token := range testMulticastMessage.Tokens { if strings.Contains(string(req), token) { @@ -894,7 +893,7 @@ func TestSendEachForMulticastPartialFailure(t *testing.T) { var failures []string ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - req, _ := ioutil.ReadAll(r.Body) + req, _ := io.ReadAll(r.Body) for idx, token := range testMulticastMessage.Tokens { if strings.Contains(string(req), token) { @@ -992,7 +991,7 @@ func TestSendAll(t *testing.T) { var req []byte ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - req, _ = ioutil.ReadAll(r.Body) + req, _ = io.ReadAll(r.Body) w.Header().Set("Content-Type", wantMime) w.Write(resp) })) @@ -1023,7 +1022,7 @@ func TestSendAllDryRun(t *testing.T) { var req []byte ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - req, _ = ioutil.ReadAll(r.Body) + req, _ = io.ReadAll(r.Body) w.Header().Set("Content-Type", wantMime) w.Write(resp) })) @@ -1053,7 +1052,7 @@ func TestSendAllPartialFailure(t *testing.T) { var req, resp []byte ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - req, _ = ioutil.ReadAll(r.Body) + req, _ = io.ReadAll(r.Body) w.Header().Set("Content-Type", wantMime) w.Write(resp) })) @@ -1296,7 +1295,7 @@ func TestSendMulticast(t *testing.T) { var req []byte ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - req, _ = ioutil.ReadAll(r.Body) + req, _ = io.ReadAll(r.Body) w.Header().Set("Content-Type", wantMime) w.Write(resp) })) @@ -1327,7 +1326,7 @@ func TestSendMulticastWithCustomEndpoint(t *testing.T) { var req []byte ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - req, _ = ioutil.ReadAll(r.Body) + req, _ = io.ReadAll(r.Body) w.Header().Set("Content-Type", wantMime) w.Write(resp) })) @@ -1367,7 +1366,7 @@ func TestSendMulticastDryRun(t *testing.T) { var req []byte ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - req, _ = ioutil.ReadAll(r.Body) + req, _ = io.ReadAll(r.Body) w.Header().Set("Content-Type", wantMime) w.Write(resp) })) @@ -1587,7 +1586,7 @@ func checkRequestPart(part *multipart.Part, dryRun bool) error { return fmt.Errorf("X-FIREBASE-CLIENT = %q; want = %q", h, clientVersion) } - b, _ := ioutil.ReadAll(r.Body) + b, _ := io.ReadAll(r.Body) var parsed map[string]interface{} if err := json.Unmarshal(b, &parsed); err != nil { return err diff --git a/messaging/messaging_test.go b/messaging/messaging_test.go index 00d4fee9..747a005a 100644 --- a/messaging/messaging_test.go +++ b/messaging/messaging_test.go @@ -17,7 +17,7 @@ package messaging import ( "context" "encoding/json" - "io/ioutil" + "io" "net/http" "net/http/httptest" "reflect" @@ -1316,7 +1316,7 @@ func TestSend(t *testing.T) { var b []byte ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { tr = r - b, _ = ioutil.ReadAll(r.Body) + b, _ = io.ReadAll(r.Body) w.Header().Set("Content-Type", "application/json") w.Write([]byte("{ \"name\":\"" + testMessageID + "\" }")) })) @@ -1345,7 +1345,7 @@ func TestSendWithCustomEndpoint(t *testing.T) { var b []byte ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { tr = r - b, _ = ioutil.ReadAll(r.Body) + b, _ = io.ReadAll(r.Body) w.Header().Set("Content-Type", "application/json") w.Write([]byte("{ \"name\":\"" + testMessageID + "\" }")) })) @@ -1382,7 +1382,7 @@ func TestSendDryRun(t *testing.T) { var b []byte ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { tr = r - b, _ = ioutil.ReadAll(r.Body) + b, _ = io.ReadAll(r.Body) w.Header().Set("Content-Type", "application/json") w.Write([]byte("{ \"name\":\"" + testMessageID + "\" }")) })) diff --git a/messaging/topic_mgt_test.go b/messaging/topic_mgt_test.go index 1b0adba9..c0703022 100644 --- a/messaging/topic_mgt_test.go +++ b/messaging/topic_mgt_test.go @@ -17,7 +17,7 @@ package messaging import ( "context" "encoding/json" - "io/ioutil" + "io" "net/http" "net/http/httptest" "reflect" @@ -33,7 +33,7 @@ func TestSubscribe(t *testing.T) { var b []byte ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { tr = r - b, _ = ioutil.ReadAll(r.Body) + b, _ = io.ReadAll(r.Body) w.Header().Set("Content-Type", "application/json") w.Write([]byte("{\"results\": [{}, {\"error\": \"error_reason\"}]}")) })) @@ -76,7 +76,7 @@ func TestUnsubscribe(t *testing.T) { var b []byte ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { tr = r - b, _ = ioutil.ReadAll(r.Body) + b, _ = io.ReadAll(r.Body) w.Header().Set("Content-Type", "application/json") w.Write([]byte("{\"results\": [{}, {\"error\": \"error_reason\"}]}")) })) diff --git a/snippets/auth.go b/snippets/auth.go index a3f8cd8a..11004a9f 100644 --- a/snippets/auth.go +++ b/snippets/auth.go @@ -18,7 +18,7 @@ import ( "context" "encoding/base64" "encoding/json" - "io/ioutil" + "io" "log" "net/http" "time" @@ -809,7 +809,7 @@ func sessionLogoutHandlerWithRevocation(client *auth.Client) http.HandlerFunc { } func getIDTokenFromBody(r *http.Request) (string, error) { - b, err := ioutil.ReadAll(r.Body) + b, err := io.ReadAll(r.Body) if err != nil { return "", err }