Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions auth/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions auth/tenant_mgt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"os"
"reflect"
"sort"
"strconv"
Expand Down Expand Up @@ -149,7 +149,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)
}
Expand Down
7 changes: 4 additions & 3 deletions auth/token_generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"os"
"strings"
"testing"

Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions auth/token_verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"encoding/pem"
"errors"
"fmt"
"io/ioutil"
"io"
"net/http"
"strconv"
"strings"
Expand Down Expand Up @@ -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
}
Expand Down
8 changes: 4 additions & 4 deletions auth/token_verifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"testing"
"time"

Expand Down Expand Up @@ -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)
}
Expand All @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down
7 changes: 4 additions & 3 deletions auth/user_mgt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"os"
"reflect"
"sort"
"strconv"
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -2301,7 +2302,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)
}
Expand Down
4 changes: 2 additions & 2 deletions db/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"net/http/httptest"
Expand Down Expand Up @@ -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
}
Expand Down
3 changes: 1 addition & 2 deletions firebase.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"context"
"encoding/json"
"errors"
"io/ioutil"
"os"

"cloud.google.com/go/firestore"
Expand Down Expand Up @@ -196,7 +195,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
}
}
Expand Down
3 changes: 1 addition & 2 deletions firebase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"net/http/httptest"
Expand Down Expand Up @@ -660,7 +659,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
}
Expand Down
6 changes: 3 additions & 3 deletions integration/auth/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"io"
"log"
"math/rand"
"net/http"
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions integration/db/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"os"
Expand Down Expand Up @@ -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)
}
Expand All @@ -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 {
Expand All @@ -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)
}
Expand Down
6 changes: 3 additions & 3 deletions integration/internal/internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ package internal
import (
"context"
"encoding/json"
"io/ioutil"
"net/http"
"os"
"path/filepath"
"strings"

Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions integration/storage/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"context"
"flag"
"fmt"
"io/ioutil"
"io"
"log"
"os"
"testing"
Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions internal/errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
"net"
"net/http"
"net/http/httptest"
Expand Down Expand Up @@ -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)
}
Expand Down
5 changes: 2 additions & 3 deletions internal/http_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"math"
"net/http"
"runtime"
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions internal/http_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"reflect"
Expand Down Expand Up @@ -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)
}
Expand Down
Loading