1
0
mirror of https://github.com/volatiletech/authboss.git synced 2025-01-08 04:03:53 +02:00

chore: remove refs to deprecated io/ioutil

This commit is contained in:
guoguangwu 2023-11-16 10:15:46 +08:00
parent 80cb1b84e9
commit 65c6e7bd74
5 changed files with 13 additions and 13 deletions

View File

@ -1,7 +1,7 @@
package defaults
import (
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"strings"
@ -16,7 +16,7 @@ func TestRouter(t *testing.T) {
wantGet, wantPost, wantDelete := "testget", "testpost", "testdelete"
r.Get("/test", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
b, err := ioutil.ReadAll(r.Body)
b, err := io.ReadAll(r.Body)
if err != nil {
panic(err)
}
@ -24,7 +24,7 @@ func TestRouter(t *testing.T) {
get = string(b)
}))
r.Post("/test", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
b, err := ioutil.ReadAll(r.Body)
b, err := io.ReadAll(r.Body)
if err != nil {
panic(err)
}
@ -32,7 +32,7 @@ func TestRouter(t *testing.T) {
post = string(b)
}))
r.Delete("/test", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
b, err := ioutil.ReadAll(r.Body)
b, err := io.ReadAll(r.Body)
if err != nil {
panic(err)
}

View File

@ -5,8 +5,8 @@ import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"net/smtp"
"os"
"testing"
"github.com/volatiletech/authboss/v3"
@ -30,7 +30,7 @@ func TestSMTPMailer(t *testing.T) {
Password string `json:"password,omitempty"`
}{}
b, err := ioutil.ReadFile("smtp_mailer_test.json")
b, err := os.ReadFile("smtp_mailer_test.json")
if err != nil {
t.Fatal(`error reading file: "smtp_mailer_test.json`, err)
}

View File

@ -2,7 +2,7 @@ package defaults
import (
"encoding/json"
"io/ioutil"
"io"
"net/http"
"net/url"
"regexp"
@ -214,7 +214,7 @@ func (h HTTPBodyReader) Read(page string, r *http.Request) (authboss.Validator,
var values map[string]string
if h.ReadJSON {
b, err := ioutil.ReadAll(r.Body)
b, err := io.ReadAll(r.Body)
r.Body.Close()
if err != nil {
return nil, errors.Wrap(err, "failed to read http body")

View File

@ -3,7 +3,7 @@ package oauth2
import (
"context"
"encoding/json"
"io/ioutil"
"io"
"net/http"
"github.com/friendsofgo/errors"
@ -40,7 +40,7 @@ func GoogleUserDetails(ctx context.Context, cfg oauth2.Config, token *oauth2.Tok
}
defer resp.Body.Close()
byt, err := ioutil.ReadAll(resp.Body)
byt, err := io.ReadAll(resp.Body)
if err != nil {
return nil, errors.Wrap(err, "failed to read body from google oauth2 endpoint")
}
@ -72,7 +72,7 @@ func FacebookUserDetails(ctx context.Context, cfg oauth2.Config, token *oauth2.T
}
defer resp.Body.Close()
byt, err := ioutil.ReadAll(resp.Body)
byt, err := io.ReadAll(resp.Body)
if err != nil {
return nil, errors.Wrap(err, "failed to read body from facebook oauth2 endpoint")
}

View File

@ -2,7 +2,7 @@ package oauth2
import (
"context"
"io/ioutil"
"io"
"net/http"
"strings"
"testing"
@ -16,7 +16,7 @@ func init() {
// get, but it'll safely be ignored.
clientGet = func(_ *http.Client, url string) (*http.Response, error) {
return &http.Response{
Body: ioutil.NopCloser(strings.NewReader(`{"id":"id", "email":"email", "name": "name"}`)),
Body: io.NopCloser(strings.NewReader(`{"id":"id", "email":"email", "name": "name"}`)),
}, nil
}
}