@@ -20,7 +20,7 @@ import (
2020 "encoding/json"
2121 "errors"
2222 "fmt"
23- "io/ioutil "
23+ "io"
2424 "net"
2525 "net/http"
2626 "net/http/httptest"
@@ -124,7 +124,7 @@ var invalidHTTPClientConfigs = []struct {
124124func newTestServer (handler func (w http.ResponseWriter , r * http.Request )) (* httptest.Server , error ) {
125125 testServer := httptest .NewUnstartedServer (http .HandlerFunc (handler ))
126126
127- tlsCAChain , err := ioutil .ReadFile (TLSCAChainPath )
127+ tlsCAChain , err := os .ReadFile (TLSCAChainPath )
128128 if err != nil {
129129 return nil , fmt .Errorf ("Can't read %s" , TLSCAChainPath )
130130 }
@@ -432,7 +432,7 @@ func TestNewClientFromConfig(t *testing.T) {
432432 continue
433433 }
434434
435- message , err := ioutil .ReadAll (response .Body )
435+ message , err := io .ReadAll (response .Body )
436436 response .Body .Close ()
437437 if err != nil {
438438 t .Errorf ("Can't read the server response body using this config: %+v" , validConfig .clientConfig )
@@ -630,7 +630,7 @@ func TestTLSConfig(t *testing.T) {
630630 InsecureSkipVerify : false ,
631631 }
632632
633- tlsCAChain , err := ioutil .ReadFile (TLSCAChainPath )
633+ tlsCAChain , err := os .ReadFile (TLSCAChainPath )
634634 if err != nil {
635635 t .Fatalf ("Can't read the CA certificate chain (%s)" ,
636636 TLSCAChainPath )
@@ -833,7 +833,7 @@ func getCertificateBlobs(t *testing.T) map[string][]byte {
833833 }
834834 bs := make (map [string ][]byte , len (files )+ 1 )
835835 for _ , f := range files {
836- b , err := ioutil .ReadFile (f )
836+ b , err := os .ReadFile (f )
837837 if err != nil {
838838 t .Fatal (err )
839839 }
@@ -848,15 +848,15 @@ func writeCertificate(bs map[string][]byte, src string, dst string) {
848848 if ! ok {
849849 panic (fmt .Sprintf ("Couldn't find %q in bs" , src ))
850850 }
851- if err := ioutil .WriteFile (dst , b , 0664 ); err != nil {
851+ if err := os .WriteFile (dst , b , 0664 ); err != nil {
852852 panic (err )
853853 }
854854}
855855
856856func TestTLSRoundTripper (t * testing.T ) {
857857 bs := getCertificateBlobs (t )
858858
859- tmpDir , err := ioutil . TempDir ("" , "tlsroundtripper" )
859+ tmpDir , err := os . MkdirTemp ("" , "tlsroundtripper" )
860860 if err != nil {
861861 t .Fatal ("Failed to create tmp dir" , err )
862862 }
@@ -976,7 +976,7 @@ func TestTLSRoundTripper(t *testing.T) {
976976 t .Fatalf ("Can't connect to the test server" )
977977 }
978978
979- b , err := ioutil .ReadAll (r .Body )
979+ b , err := io .ReadAll (r .Body )
980980 r .Body .Close ()
981981 if err != nil {
982982 t .Errorf ("Can't read the server response body" )
@@ -993,7 +993,7 @@ func TestTLSRoundTripper(t *testing.T) {
993993func TestTLSRoundTripperRaces (t * testing.T ) {
994994 bs := getCertificateBlobs (t )
995995
996- tmpDir , err := ioutil . TempDir ("" , "tlsroundtripper" )
996+ tmpDir , err := os . MkdirTemp ("" , "tlsroundtripper" )
997997 if err != nil {
998998 t .Fatal ("Failed to create tmp dir" , err )
999999 }
@@ -1137,7 +1137,7 @@ func LoadHTTPConfig(s string) (*HTTPClientConfig, error) {
11371137
11381138// LoadHTTPConfigFile parses the given YAML file into a HTTPClientConfig.
11391139func LoadHTTPConfigFile (filename string ) (* HTTPClientConfig , []byte , error ) {
1140- content , err := ioutil .ReadFile (filename )
1140+ content , err := os .ReadFile (filename )
11411141 if err != nil {
11421142 return nil , nil , err
11431143 }
@@ -1305,7 +1305,7 @@ func TestOAuth2WithFile(t *testing.T) {
13051305 }))
13061306 defer ts .Close ()
13071307
1308- secretFile , err := ioutil . TempFile ("" , "oauth2_secret" )
1308+ secretFile , err := os . CreateTemp ("" , "oauth2_secret" )
13091309 if err != nil {
13101310 t .Fatal (err )
13111311 }
0 commit comments