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
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
"net/http"
"strings"

Expand Down Expand Up @@ -103,7 +103,7 @@ func (a *Authenticator) AuthenticatePassword(ctx context.Context, username, pass
return nil, false, nil
}

body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, false, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"testing"

Expand Down Expand Up @@ -59,7 +59,7 @@ func TestKeystoneLogin(t *testing.T) {
}
}
var x AuthRequest
body, _ := ioutil.ReadAll(r.Body)
body, _ := io.ReadAll(r.Body)
th.AssertNoErr(t, json.Unmarshal(body, &x))
domainName := x.Auth.Identity.Password.User.Domain.Name
userName := x.Auth.Identity.Password.User.Name
Expand Down
3 changes: 1 addition & 2 deletions pkg/cmd/oauth-server/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"os"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -86,7 +85,7 @@ func (o *OsinServerOptions) Validate() error {
}

func (o *OsinServerOptions) RunOsinServer(stopCh <-chan struct{}) error {
configContent, err := ioutil.ReadFile(o.ConfigFile)
configContent, err := os.ReadFile(o.ConfigFile)
if err != nil {
return err
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/config/stringsource.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"crypto/x509"
"encoding/pem"
"fmt"
"io/ioutil"
"os"

"k8s.io/apimachinery/pkg/util/sets"
Expand All @@ -31,7 +30,7 @@ func ResolveStringValue(s configv1.StringSource) (string, error) {
case len(s.Env) > 0:
value = os.Getenv(s.Env)
case len(s.File) > 0:
data, err := ioutil.ReadFile(s.File)
data, err := os.ReadFile(s.File)
if err != nil {
return "", err
}
Expand All @@ -45,7 +44,7 @@ func ResolveStringValue(s configv1.StringSource) (string, error) {
return value, nil
}

keyData, err := ioutil.ReadFile(s.KeyFile)
keyData, err := os.ReadFile(s.KeyFile)
if err != nil {
return "", err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/oauth/external/gitlab/gitlab_oauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/url"

Expand Down Expand Up @@ -95,7 +95,7 @@ func (p *provider) GetUserIdentity(data *osincli.AccessData) (authapi.UserIdenti
}
defer res.Body.Close()

body, err := ioutil.ReadAll(res.Body)
body, err := io.ReadAll(res.Body)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/oauth/external/openid/openid.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/url"
"strings"
Expand Down Expand Up @@ -273,7 +273,7 @@ func fetchUserInfo(url, accessToken string, transport http.RoundTripper) (map[st

// The UserInfo Claims MUST be returned as the members of a JSON object
// http://openid.net/specs/openid-connect-core-1_0.html#UserInfoResponse
data, err := ioutil.ReadAll(resp.Body)
data, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/oauthserver/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"crypto/x509"
"errors"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"os"
"path"
"strings"

Expand Down Expand Up @@ -685,7 +685,7 @@ func (c *OAuthServerConfig) getAuthenticationRequestHandler() (authenticator.Req

// Wrap with an x509 verifier
if len(provider.ClientCA) > 0 {
caData, err := ioutil.ReadFile(provider.ClientCA)
caData, err := os.ReadFile(provider.ClientCA)
if err != nil {
return nil, fmt.Errorf("Error reading %s: %v", provider.ClientCA, err)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/oauthserver/oauth_apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"crypto/sha256"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"os"
"time"

"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -200,7 +200,7 @@ func getSessionSecrets(filename string) ([][]byte, error) {
var secrets [][]byte

if len(filename) != 0 {
data, err := ioutil.ReadFile(filename)
data, err := os.ReadFile(filename)
if err != nil {
return nil, err
}
Expand Down
13 changes: 6 additions & 7 deletions pkg/oauthserver/oauth_apiserver_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package oauthserver

import (
"io/ioutil"
"os"
"reflect"
"testing"
Expand All @@ -28,13 +27,13 @@ func TestGetMissingSessionSecretsFile(t *testing.T) {
}

func TestGetInvalidSessionSecretsFile(t *testing.T) {
tmpfile, err := ioutil.TempFile("", "invalid.yaml")
tmpfile, err := os.CreateTemp("", "invalid.yaml")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
defer os.Remove(tmpfile.Name())

if err := ioutil.WriteFile(tmpfile.Name(), []byte("invalid content"), os.FileMode(0600)); err != nil {
if err := os.WriteFile(tmpfile.Name(), []byte("invalid content"), os.FileMode(0600)); err != nil {
t.Fatal(err)
}

Expand All @@ -45,7 +44,7 @@ func TestGetInvalidSessionSecretsFile(t *testing.T) {
}

func TestGetEmptySessionSecretsFile(t *testing.T) {
tmpfile, err := ioutil.TempFile("", "empty.yaml")
tmpfile, err := os.CreateTemp("", "empty.yaml")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
Expand All @@ -59,7 +58,7 @@ func TestGetEmptySessionSecretsFile(t *testing.T) {
if err != nil {
t.Errorf("Unexpected error: %v", err)
}
if err := ioutil.WriteFile(tmpfile.Name(), []byte(yaml), os.FileMode(0600)); err != nil {
if err := os.WriteFile(tmpfile.Name(), []byte(yaml), os.FileMode(0600)); err != nil {
t.Fatal(err)
}

Expand All @@ -70,7 +69,7 @@ func TestGetEmptySessionSecretsFile(t *testing.T) {
}

func TestGetValidSessionSecretsFile(t *testing.T) {
tmpfile, err := ioutil.TempFile("", "valid.yaml")
tmpfile, err := os.CreateTemp("", "valid.yaml")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
Expand All @@ -88,7 +87,7 @@ func TestGetValidSessionSecretsFile(t *testing.T) {
if err != nil {
t.Errorf("Unexpected error: %v", err)
}
if err := ioutil.WriteFile(tmpfile.Name(), []byte(yaml), os.FileMode(0600)); err != nil {
if err := os.WriteFile(tmpfile.Name(), []byte(yaml), os.FileMode(0600)); err != nil {
t.Fatal(err)
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/server/grant/grant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package grant

import (
"errors"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"net/url"
Expand Down Expand Up @@ -467,7 +467,7 @@ func TestGrant(t *testing.T) {
}

if len(testCase.ExpectContains) > 0 {
data, _ := ioutil.ReadAll(resp.Body)
data, _ := io.ReadAll(resp.Body)
body := string(data)
for i := range testCase.ExpectContains {
if !strings.Contains(body, testCase.ExpectContains[i]) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/server/login/login_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package login
import (
"context"
"errors"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"net/url"
Expand Down Expand Up @@ -246,7 +246,7 @@ func TestLogin(t *testing.T) {
}

if len(testCase.ExpectContains) > 0 {
data, _ := ioutil.ReadAll(resp.Body)
data, _ := io.ReadAll(resp.Body)
body := string(data)
for i := range testCase.ExpectContains {
if !strings.Contains(body, testCase.ExpectContains[i]) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/server/selectprovider/selectprovider_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package selectprovider

import (
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"strings"
Expand Down Expand Up @@ -96,7 +96,7 @@ func TestSelectAuthentication(t *testing.T) {
}

if len(testCase.ExpectContains) > 0 {
data, _ := ioutil.ReadAll(resp.Body)
data, _ := io.ReadAll(resp.Body)
body := string(data)
for i := range testCase.ExpectContains {
if !strings.Contains(body, testCase.ExpectContains[i]) {
Expand Down