refactor: move from io/ioutil to io and os package

The io/ioutil package has been deprecated as of Go 1.16, see
https://golang.org/doc/go1.16#ioutil. This commit replaces the existing
io/ioutil functions with their new definitions in io and os packages.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
Eng Zer Jun
2021-09-17 14:12:39 +08:00
parent 40b426b276
commit f0186ff265
25 changed files with 69 additions and 72 deletions

View File

@@ -5,7 +5,7 @@ import (
"encoding/base64"
"encoding/pem"
"errors"
"io/ioutil"
"os"
"sort"
"testing"
"time"
@@ -392,7 +392,7 @@ func TestTamperedResponseNameID(t *testing.T) {
}
func loadCert(ca string) (*x509.Certificate, error) {
data, err := ioutil.ReadFile(ca)
data, err := os.ReadFile(ca)
if err != nil {
return nil, err
}
@@ -426,7 +426,7 @@ func (r responseTest) run(t *testing.T) {
t.Fatal(err)
}
conn.now = func() time.Time { return now }
resp, err := ioutil.ReadFile(r.respFile)
resp, err := os.ReadFile(r.respFile)
if err != nil {
t.Fatal(err)
}
@@ -456,11 +456,11 @@ func (r responseTest) run(t *testing.T) {
func TestConfigCAData(t *testing.T) {
logger := logrus.New()
validPEM, err := ioutil.ReadFile("testdata/ca.crt")
validPEM, err := os.ReadFile("testdata/ca.crt")
if err != nil {
t.Fatal(err)
}
valid2ndPEM, err := ioutil.ReadFile("testdata/okta-ca.pem")
valid2ndPEM, err := os.ReadFile("testdata/okta-ca.pem")
if err != nil {
t.Fatal(err)
}
@@ -551,7 +551,7 @@ func runVerify(t *testing.T, ca string, resp string, shouldSucceed bool) {
validator := dsig.NewDefaultValidationContext(s)
data, err := ioutil.ReadFile(resp)
data, err := os.ReadFile(resp)
if err != nil {
t.Fatal(err)
}