git.iko.soy/typeable/oauth2-proxy
on master help sign in
Fix Linting Errors (#1835)
7fe6384Andrew Hamade
docs/docs/configuration/alpha_config.md+3−2
@@ -306,7 +306,7 @@ the caller provides it, and no value will be sent otherwise.
306
306
307Examples:
307Examples:
308
308
309−A parameter whose value is fixed
309+# A parameter whose value is fixed
310
310
311```
311```
312name: organization
312name: organization
@@ -354,8 +354,9 @@ as backslash is not considered to be an escape character. Alternatively
354use the "chomped block" format `|-`:
354use the "chomped block" format `|-`:
355
355
356```
356```
357−- pattern: |-
357+ - pattern: |-
358 ^[^@]*@example\.com$
358 ^[^@]*@example\.com$
359+
359```
360```
360
361
361The hyphen is important, a `|` block would have a trailing newline
362The hyphen is important, a `|` block would have a trailing newline
main_test.go+2−3
@@ -3,7 +3,6 @@ package main
3import (
3import (
4 "errors"
4 "errors"
5 "fmt"
5 "fmt"
6− "io/ioutil"
7 "os"
6 "os"
8 "strings"
7 "strings"
9 "time"
8 "time"
@@ -191,7 +190,7 @@ redirect_url="http://localhost:4180/oauth2/callback"
191
190
192 if in.configContent != "" {
191 if in.configContent != "" {
193 By("Writing the config to a temporary file", func() {
192 By("Writing the config to a temporary file", func() {
194− file, err := ioutil.TempFile("", "oauth2-proxy-test-config-XXXX.cfg")
193+ file, err := os.CreateTemp("", "oauth2-proxy-test-config-XXXX.cfg")
195 Expect(err).ToNot(HaveOccurred())
194 Expect(err).ToNot(HaveOccurred())
196 defer file.Close()
195 defer file.Close()
197
196
@@ -204,7 +203,7 @@ redirect_url="http://localhost:4180/oauth2/callback"
204
203
205 if in.alphaConfigContent != "" {
204 if in.alphaConfigContent != "" {
206 By("Writing the config to a temporary file", func() {
205 By("Writing the config to a temporary file", func() {
207− file, err := ioutil.TempFile("", "oauth2-proxy-test-alpha-config-XXXX.yaml")
206+ file, err := os.CreateTemp("", "oauth2-proxy-test-alpha-config-XXXX.yaml")
208 Expect(err).ToNot(HaveOccurred())
207 Expect(err).ToNot(HaveOccurred())
209 defer file.Close()
208 defer file.Close()
210
209
oauthproxy_test.go+8−9
@@ -6,7 +6,6 @@ import (
6 "encoding/base64"
6 "encoding/base64"
7 "fmt"
7 "fmt"
8 "io"
8 "io"
9− "io/ioutil"
10 "net/http"
9 "net/http"
11 "net/http/httptest"
10 "net/http/httptest"
12 "net/url"
11 "net/url"
@@ -837,9 +836,9 @@ func NewProcessCookieTest(opts ProcessCookieTestOpts, modifiers ...OptionsModifi
837 }
836 }
838
837
839 groups := pcTest.opts.Providers[0].AllowedGroups
838 groups := pcTest.opts.Providers[0].AllowedGroups
840− testProvider.AllowedGroups = make(map[string]struct{}, len(groups))
839+ testProvider.ProviderData.AllowedGroups = make(map[string]struct{}, len(groups))
841 for _, group := range groups {
840 for _, group := range groups {
842− testProvider.AllowedGroups[group] = struct{}{}
841+ testProvider.ProviderData.AllowedGroups[group] = struct{}{}
843 }
842 }
844 pcTest.proxy.provider = testProvider
843 pcTest.proxy.provider = testProvider
845
844
@@ -1043,7 +1042,7 @@ func TestUserInfoEndpointAccepted(t *testing.T) {
1043
1042
1044 test.proxy.ServeHTTP(test.rw, test.req)
1043 test.proxy.ServeHTTP(test.rw, test.req)
1045 assert.Equal(t, http.StatusOK, test.rw.Code)
1044 assert.Equal(t, http.StatusOK, test.rw.Code)
1046− bodyBytes, _ := ioutil.ReadAll(test.rw.Body)
1045+ bodyBytes, _ := io.ReadAll(test.rw.Body)
1047 assert.Equal(t, tc.expectedResponse, string(bodyBytes))
1046 assert.Equal(t, tc.expectedResponse, string(bodyBytes))
1048 })
1047 })
1049 }
1048 }
@@ -1094,7 +1093,7 @@ func TestAuthOnlyEndpointAccepted(t *testing.T) {
1094
1093
1095 test.proxy.ServeHTTP(test.rw, test.req)
1094 test.proxy.ServeHTTP(test.rw, test.req)
1096 assert.Equal(t, http.StatusAccepted, test.rw.Code)
1095 assert.Equal(t, http.StatusAccepted, test.rw.Code)
1097− bodyBytes, _ := ioutil.ReadAll(test.rw.Body)
1096+ bodyBytes, _ := io.ReadAll(test.rw.Body)
1098 assert.Equal(t, "", string(bodyBytes))
1097 assert.Equal(t, "", string(bodyBytes))
1099}
1098}
1100
1099
@@ -1106,7 +1105,7 @@ func TestAuthOnlyEndpointUnauthorizedOnNoCookieSetError(t *testing.T) {
1106
1105
1107 test.proxy.ServeHTTP(test.rw, test.req)
1106 test.proxy.ServeHTTP(test.rw, test.req)
1108 assert.Equal(t, http.StatusUnauthorized, test.rw.Code)
1107 assert.Equal(t, http.StatusUnauthorized, test.rw.Code)
1109− bodyBytes, _ := ioutil.ReadAll(test.rw.Body)
1108+ bodyBytes, _ := io.ReadAll(test.rw.Body)
1110 assert.Equal(t, "Unauthorized\n", string(bodyBytes))
1109 assert.Equal(t, "Unauthorized\n", string(bodyBytes))
1111}
1110}
1112
1111
@@ -1126,7 +1125,7 @@ func TestAuthOnlyEndpointUnauthorizedOnExpiration(t *testing.T) {
1126
1125
1127 test.proxy.ServeHTTP(test.rw, test.req)
1126 test.proxy.ServeHTTP(test.rw, test.req)
1128 assert.Equal(t, http.StatusUnauthorized, test.rw.Code)
1127 assert.Equal(t, http.StatusUnauthorized, test.rw.Code)
1129− bodyBytes, _ := ioutil.ReadAll(test.rw.Body)
1128+ bodyBytes, _ := io.ReadAll(test.rw.Body)
1130 assert.Equal(t, "Unauthorized\n", string(bodyBytes))
1129 assert.Equal(t, "Unauthorized\n", string(bodyBytes))
1131}
1130}
1132
1131
@@ -1145,7 +1144,7 @@ func TestAuthOnlyEndpointUnauthorizedOnEmailValidationFailure(t *testing.T) {
1145
1144
1146 test.proxy.ServeHTTP(test.rw, test.req)
1145 test.proxy.ServeHTTP(test.rw, test.req)
1147 assert.Equal(t, http.StatusUnauthorized, test.rw.Code)
1146 assert.Equal(t, http.StatusUnauthorized, test.rw.Code)
1148− bodyBytes, _ := ioutil.ReadAll(test.rw.Body)
1147+ bodyBytes, _ := io.ReadAll(test.rw.Body)
1149 assert.Equal(t, "Unauthorized\n", string(bodyBytes))
1148 assert.Equal(t, "Unauthorized\n", string(bodyBytes))
1150}
1149}
1151
1150
@@ -1561,7 +1560,7 @@ func (st *SignatureTest) MakeRequestWithExpectedKey(method, body, key string) er
1561
1560
1562 var bodyBuf io.ReadCloser
1561 var bodyBuf io.ReadCloser
1563 if body != "" {
1562 if body != "" {
1564− bodyBuf = ioutil.NopCloser(&fakeNetConn{reqBody: body})
1563+ bodyBuf = io.NopCloser(&fakeNetConn{reqBody: body})
1565 }
1564 }
1566 req := httptest.NewRequest(method, "/foo/bar", bodyBuf)
1565 req := httptest.NewRequest(method, "/foo/bar", bodyBuf)
1567 req.Header = st.header
1566 req.Header = st.header
pkg/apis/options/load.go+5−3
@@ -3,7 +3,7 @@ package options
3import (
3import (
4 "errors"
4 "errors"
5 "fmt"
5 "fmt"
6− "io/ioutil"
6+ "os"
7 "reflect"
7 "reflect"
8 "strings"
8 "strings"
9
9
@@ -17,7 +17,9 @@ import (
17// variables (prefixed with `OAUTH2_PROXY`) and finally merges in flags from the flagSet.
17// variables (prefixed with `OAUTH2_PROXY`) and finally merges in flags from the flagSet.
18// If a config value is unset and the flag has a non-zero value default, this default will be used.
18// If a config value is unset and the flag has a non-zero value default, this default will be used.
19// Eg. A field defined:
19// Eg. A field defined:
20+//
20−// FooBar `cfg:"foo_bar" flag:"foo-bar"`
21+// FooBar `cfg:"foo_bar" flag:"foo-bar"`
22+//
21// Can be set in the config file as `foo_bar="baz"`, in the environment as `OAUTH2_PROXY_FOO_BAR=baz`,
23// Can be set in the config file as `foo_bar="baz"`, in the environment as `OAUTH2_PROXY_FOO_BAR=baz`,
22// or via the command line flag `--foo-bar=baz`.
24// or via the command line flag `--foo-bar=baz`.
23func Load(configFileName string, flagSet *pflag.FlagSet, into interface{}) error {
25func Load(configFileName string, flagSet *pflag.FlagSet, into interface{}) error {
@@ -147,7 +149,7 @@ func LoadYAML(configFileName string, into interface{}) error {
147 return errors.New("no configuration file provided")
149 return errors.New("no configuration file provided")
148 }
150 }
149
151
150− data, err := ioutil.ReadFile(configFileName)
152+ data, err := os.ReadFile(configFileName)
151 if err != nil {
153 if err != nil {
152 return fmt.Errorf("unable to load config file: %w", err)
154 return fmt.Errorf("unable to load config file: %w", err)
153 }
155 }
pkg/apis/options/load_test.go+3−4
@@ -3,7 +3,6 @@ package options
3import (
3import (
4 "errors"
4 "errors"
5 "fmt"
5 "fmt"
6− "io/ioutil"
7 "os"
6 "os"
8 "time"
7 "time"
9
8
@@ -118,7 +117,7 @@ var _ = Describe("Load", func() {
118
117
119 if o.configFile != nil {
118 if o.configFile != nil {
120 By("Creating a config file")
119 By("Creating a config file")
121− configFile, err := ioutil.TempFile("", "oauth2-proxy-test-legacy-config-file")
120+ configFile, err := os.CreateTemp("", "oauth2-proxy-test-legacy-config-file")
122 Expect(err).ToNot(HaveOccurred())
121 Expect(err).ToNot(HaveOccurred())
123 defer configFile.Close()
122 defer configFile.Close()
124
123
@@ -390,7 +389,7 @@ sub:
390
389
391 if in.configFile != nil {
390 if in.configFile != nil {
392 By("Creating a config file")
391 By("Creating a config file")
393− configFile, err := ioutil.TempFile("", "oauth2-proxy-test-config-file")
392+ configFile, err := os.CreateTemp("", "oauth2-proxy-test-config-file")
394 Expect(err).ToNot(HaveOccurred())
393 Expect(err).ToNot(HaveOccurred())
395 defer configFile.Close()
394 defer configFile.Close()
396
395
@@ -488,7 +487,7 @@ injectResponseHeaders:
488`)
487`)
489
488
490 By("Creating a config file")
489 By("Creating a config file")
491− configFile, err := ioutil.TempFile("", "oauth2-proxy-test-alpha-config-file")
490+ configFile, err := os.CreateTemp("", "oauth2-proxy-test-alpha-config-file")
492 Expect(err).ToNot(HaveOccurred())
491 Expect(err).ToNot(HaveOccurred())
493 defer configFile.Close()
492 defer configFile.Close()
494
493
pkg/apis/options/login_url_parameters.go+3−2
@@ -14,7 +14,7 @@ package options
14//
14//
15// Examples:
15// Examples:
16//
16//
17−// A parameter whose value is fixed
17+// # A parameter whose value is fixed
18//
18//
19// ```
19// ```
20// name: organization
20// name: organization
@@ -62,8 +62,9 @@ package options
62// use the "chomped block" format `|-`:
62// use the "chomped block" format `|-`:
63//
63//
64// ```
64// ```
65−// - pattern: |-
65+// - pattern: |-
66// ^[^@]*@example\.com$
66// ^[^@]*@example\.com$
67+//
67// ```
68// ```
68//
69//
69// The hyphen is important, a `|` block would have a trailing newline
70// The hyphen is important, a `|` block would have a trailing newline
pkg/apis/options/util/util.go+1−2
@@ -2,7 +2,6 @@ package util
2
2
3import (
3import (
4 "errors"
4 "errors"
5− "io/ioutil"
6 "os"
5 "os"
7
6
8 "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options"
7 "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options"
@@ -16,7 +15,7 @@ func GetSecretValue(source *options.SecretSource) ([]byte, error) {
16 case len(source.Value) == 0 && source.FromEnv != "" && source.FromFile == "":
15 case len(source.Value) == 0 && source.FromEnv != "" && source.FromFile == "":
17 return []byte(os.Getenv(source.FromEnv)), nil
16 return []byte(os.Getenv(source.FromEnv)), nil
18 case len(source.Value) == 0 && source.FromEnv == "" && source.FromFile != "":
17 case len(source.Value) == 0 && source.FromEnv == "" && source.FromFile != "":
19− return ioutil.ReadFile(source.FromFile)
18+ return os.ReadFile(source.FromFile)
20 default:
19 default:
21 return nil, errors.New("secret source is invalid: exactly one entry required, specify either value, fromEnv or fromFile")
20 return nil, errors.New("secret source is invalid: exactly one entry required, specify either value, fromEnv or fromFile")
22 }
21 }
pkg/apis/options/util/util_test.go+2−3
@@ -1,7 +1,6 @@
1package util
1package util
2
2
3import (
3import (
4− "io/ioutil"
5 "os"
4 "os"
6 "path"
5 "path"
7
6
@@ -20,9 +19,9 @@ var _ = Describe("GetSecretValue", func() {
20 os.Setenv(secretEnvKey, secretEnvValue)
19 os.Setenv(secretEnvKey, secretEnvValue)
21
20
22 var err error
21 var err error
23− fileDir, err = ioutil.TempDir("", "oauth2-proxy-util-get-secret-value")
22+ fileDir, err = os.MkdirTemp("", "oauth2-proxy-util-get-secret-value")
24 Expect(err).ToNot(HaveOccurred())
23 Expect(err).ToNot(HaveOccurred())
25− Expect(ioutil.WriteFile(path.Join(fileDir, "secret-file"), secretFileValue, 0600)).To(Succeed())
24+ Expect(os.WriteFile(path.Join(fileDir, "secret-file"), secretFileValue, 0600)).To(Succeed())
26 })
25 })
27
26
28 AfterEach(func() {
27 AfterEach(func() {
pkg/apis/sessions/session_state.go+2−3
@@ -5,7 +5,6 @@ import (
5 "context"
5 "context"
6 "fmt"
6 "fmt"
7 "io"
7 "io"
8− "io/ioutil"
9 "time"
8 "time"
10
9
11 "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/clock"
10 "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/clock"
@@ -225,7 +224,7 @@ func lz4Compress(payload []byte) ([]byte, error) {
225 return nil, fmt.Errorf("error closing lz4 writer: %w", err)
224 return nil, fmt.Errorf("error closing lz4 writer: %w", err)
226 }
225 }
227
226
228− compressed, err := ioutil.ReadAll(buf)
227+ compressed, err := io.ReadAll(buf)
229 if err != nil {
228 if err != nil {
230 return nil, fmt.Errorf("error reading lz4 buffer: %w", err)
229 return nil, fmt.Errorf("error reading lz4 buffer: %w", err)
231 }
230 }
@@ -244,7 +243,7 @@ func lz4Decompress(compressed []byte) ([]byte, error) {
244 return nil, fmt.Errorf("error copying lz4 stream to buffer: %w", err)
243 return nil, fmt.Errorf("error copying lz4 stream to buffer: %w", err)
245 }
244 }
246
245
247− payload, err := ioutil.ReadAll(buf)
246+ payload, err := io.ReadAll(buf)
248 if err != nil {
247 if err != nil {
249 return nil, fmt.Errorf("error reading lz4 buffer: %w", err)
248 return nil, fmt.Errorf("error reading lz4 buffer: %w", err)
250 }
249 }
pkg/app/pagewriter/error_page_test.go+8−8
@@ -3,7 +3,7 @@ package pagewriter
3import (
3import (
4 "errors"
4 "errors"
5 "html/template"
5 "html/template"
6− "io/ioutil"
6+ "io"
7 "net/http/httptest"
7 "net/http/httptest"
8
8
9 middlewareapi "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/middleware"
9 middlewareapi "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/middleware"
@@ -36,7 +36,7 @@ var _ = Describe("Error Page Writer", func() {
36 AppError: "Access Denied",
36 AppError: "Access Denied",
37 })
37 })
38
38
39− body, err := ioutil.ReadAll(recorder.Result().Body)
39+ body, err := io.ReadAll(recorder.Result().Body)
40 Expect(err).ToNot(HaveOccurred())
40 Expect(err).ToNot(HaveOccurred())
41 Expect(string(body)).To(Equal("Forbidden You do not have permission to access this resource. /prefix/ 403 /redirect 11111111-2222-4333-8444-555555555555 Custom Footer Text v0.0.0-test"))
41 Expect(string(body)).To(Equal("Forbidden You do not have permission to access this resource. /prefix/ 403 /redirect 11111111-2222-4333-8444-555555555555 Custom Footer Text v0.0.0-test"))
42 })
42 })
@@ -50,7 +50,7 @@ var _ = Describe("Error Page Writer", func() {
50 AppError: "Access Denied",
50 AppError: "Access Denied",
51 })
51 })
52
52
53− body, err := ioutil.ReadAll(recorder.Result().Body)
53+ body, err := io.ReadAll(recorder.Result().Body)
54 Expect(err).ToNot(HaveOccurred())
54 Expect(err).ToNot(HaveOccurred())
55 Expect(string(body)).To(Equal("Internal Server Error Oops! Something went wrong. For more information contact your server administrator. /prefix/ 500 /redirect 11111111-2222-4333-8444-555555555555 Custom Footer Text v0.0.0-test"))
55 Expect(string(body)).To(Equal("Internal Server Error Oops! Something went wrong. For more information contact your server administrator. /prefix/ 500 /redirect 11111111-2222-4333-8444-555555555555 Custom Footer Text v0.0.0-test"))
56 })
56 })
@@ -68,7 +68,7 @@ var _ = Describe("Error Page Writer", func() {
68 },
68 },
69 })
69 })
70
70
71− body, err := ioutil.ReadAll(recorder.Result().Body)
71+ body, err := io.ReadAll(recorder.Result().Body)
72 Expect(err).ToNot(HaveOccurred())
72 Expect(err).ToNot(HaveOccurred())
73 Expect(string(body)).To(Equal("Forbidden An extra message: with more context. /prefix/ 403 /redirect 11111111-2222-4333-8444-555555555555 Custom Footer Text v0.0.0-test"))
73 Expect(string(body)).To(Equal("Forbidden An extra message: with more context. /prefix/ 403 /redirect 11111111-2222-4333-8444-555555555555 Custom Footer Text v0.0.0-test"))
74 })
74 })
@@ -82,7 +82,7 @@ var _ = Describe("Error Page Writer", func() {
82 AppError: "Access Denied",
82 AppError: "Access Denied",
83 })
83 })
84
84
85− body, err := ioutil.ReadAll(recorder.Result().Body)
85+ body, err := io.ReadAll(recorder.Result().Body)
86 Expect(err).ToNot(HaveOccurred())
86 Expect(err).ToNot(HaveOccurred())
87 Expect(string(body)).To(Equal("Forbidden You do not have permission to access this resource. /prefix/ 403 /redirect <script>alert(1)</script> Custom Footer Text v0.0.0-test"))
87 Expect(string(body)).To(Equal("Forbidden You do not have permission to access this resource. /prefix/ 403 /redirect <script>alert(1)</script> Custom Footer Text v0.0.0-test"))
88 })
88 })
@@ -97,7 +97,7 @@ var _ = Describe("Error Page Writer", func() {
97 recorder := httptest.NewRecorder()
97 recorder := httptest.NewRecorder()
98 errorPage.ProxyErrorHandler(recorder, req, errors.New("some upstream error"))
98 errorPage.ProxyErrorHandler(recorder, req, errors.New("some upstream error"))
99
99
100− body, err := ioutil.ReadAll(recorder.Result().Body)
100+ body, err := io.ReadAll(recorder.Result().Body)
101 Expect(err).ToNot(HaveOccurred())
101 Expect(err).ToNot(HaveOccurred())
102 Expect(string(body)).To(Equal("Bad Gateway There was a problem connecting to the upstream server. /prefix/ 502 11111111-2222-4333-8444-555555555555 Custom Footer Text v0.0.0-test"))
102 Expect(string(body)).To(Equal("Bad Gateway There was a problem connecting to the upstream server. /prefix/ 502 11111111-2222-4333-8444-555555555555 Custom Footer Text v0.0.0-test"))
103 })
103 })
@@ -121,7 +121,7 @@ var _ = Describe("Error Page Writer", func() {
121 AppError: "Debug error",
121 AppError: "Debug error",
122 })
122 })
123
123
124− body, err := ioutil.ReadAll(recorder.Result().Body)
124+ body, err := io.ReadAll(recorder.Result().Body)
125 Expect(err).ToNot(HaveOccurred())
125 Expect(err).ToNot(HaveOccurred())
126 Expect(string(body)).To(Equal("Debug error"))
126 Expect(string(body)).To(Equal("Debug error"))
127 })
127 })
@@ -136,7 +136,7 @@ var _ = Describe("Error Page Writer", func() {
136 recorder := httptest.NewRecorder()
136 recorder := httptest.NewRecorder()
137 errorPage.ProxyErrorHandler(recorder, req, errors.New("some upstream error"))
137 errorPage.ProxyErrorHandler(recorder, req, errors.New("some upstream error"))
138
138
139− body, err := ioutil.ReadAll(recorder.Result().Body)
139+ body, err := io.ReadAll(recorder.Result().Body)
140 Expect(err).ToNot(HaveOccurred())
140 Expect(err).ToNot(HaveOccurred())
141 Expect(string(body)).To(Equal("some upstream error"))
141 Expect(string(body)).To(Equal("some upstream error"))
142 })
142 })
pkg/app/pagewriter/pagewriter_test.go+14−14
@@ -3,7 +3,7 @@ package pagewriter
3import (
3import (
4 "errors"
4 "errors"
5 "fmt"
5 "fmt"
6− "io/ioutil"
6+ "io"
7 "net/http"
7 "net/http"
8 "net/http/httptest"
8 "net/http/httptest"
9 "os"
9 "os"
@@ -50,7 +50,7 @@ var _ = Describe("Writer", func() {
50 AppError: "Some debug error",
50 AppError: "Some debug error",
51 })
51 })
52
52
53− body, err := ioutil.ReadAll(recorder.Result().Body)
53+ body, err := io.ReadAll(recorder.Result().Body)
54 Expect(err).ToNot(HaveOccurred())
54 Expect(err).ToNot(HaveOccurred())
55 Expect(string(body)).To(HavePrefix("\n<!DOCTYPE html>"))
55 Expect(string(body)).To(HavePrefix("\n<!DOCTYPE html>"))
56 })
56 })
@@ -59,7 +59,7 @@ var _ = Describe("Writer", func() {
59 recorder := httptest.NewRecorder()
59 recorder := httptest.NewRecorder()
60 writer.WriteSignInPage(recorder, request, "/redirect", http.StatusOK)
60 writer.WriteSignInPage(recorder, request, "/redirect", http.StatusOK)
61
61
62− body, err := ioutil.ReadAll(recorder.Result().Body)
62+ body, err := io.ReadAll(recorder.Result().Body)
63 Expect(err).ToNot(HaveOccurred())
63 Expect(err).ToNot(HaveOccurred())
64 Expect(string(body)).To(HavePrefix("\n<!DOCTYPE html>"))
64 Expect(string(body)).To(HavePrefix("\n<!DOCTYPE html>"))
65 })
65 })
@@ -70,14 +70,14 @@ var _ = Describe("Writer", func() {
70
70
71 BeforeEach(func() {
71 BeforeEach(func() {
72 var err error
72 var err error
73− customDir, err = ioutil.TempDir("", "oauth2-proxy-pagewriter-test")
73+ customDir, err = os.MkdirTemp("", "oauth2-proxy-pagewriter-test")
74 Expect(err).ToNot(HaveOccurred())
74 Expect(err).ToNot(HaveOccurred())
75
75
76 templateHTML := `Custom Template`
76 templateHTML := `Custom Template`
77 signInFile := filepath.Join(customDir, signInTemplateName)
77 signInFile := filepath.Join(customDir, signInTemplateName)
78− Expect(ioutil.WriteFile(signInFile, []byte(templateHTML), 0600)).To(Succeed())
78+ Expect(os.WriteFile(signInFile, []byte(templateHTML), 0600)).To(Succeed())
79 errorFile := filepath.Join(customDir, errorTemplateName)
79 errorFile := filepath.Join(customDir, errorTemplateName)
80− Expect(ioutil.WriteFile(errorFile, []byte(templateHTML), 0600)).To(Succeed())
80+ Expect(os.WriteFile(errorFile, []byte(templateHTML), 0600)).To(Succeed())
81
81
82 opts.TemplatesPath = customDir
82 opts.TemplatesPath = customDir
83
83
@@ -97,7 +97,7 @@ var _ = Describe("Writer", func() {
97 AppError: "Some debug error",
97 AppError: "Some debug error",
98 })
98 })
99
99
100− body, err := ioutil.ReadAll(recorder.Result().Body)
100+ body, err := io.ReadAll(recorder.Result().Body)
101 Expect(err).ToNot(HaveOccurred())
101 Expect(err).ToNot(HaveOccurred())
102 Expect(string(body)).To(Equal("Custom Template"))
102 Expect(string(body)).To(Equal("Custom Template"))
103 })
103 })
@@ -106,7 +106,7 @@ var _ = Describe("Writer", func() {
106 recorder := httptest.NewRecorder()
106 recorder := httptest.NewRecorder()
107 writer.WriteSignInPage(recorder, request, "/redirect", http.StatusOK)
107 writer.WriteSignInPage(recorder, request, "/redirect", http.StatusOK)
108
108
109− body, err := ioutil.ReadAll(recorder.Result().Body)
109+ body, err := io.ReadAll(recorder.Result().Body)
110 Expect(err).ToNot(HaveOccurred())
110 Expect(err).ToNot(HaveOccurred())
111 Expect(string(body)).To(Equal("Custom Template"))
111 Expect(string(body)).To(Equal("Custom Template"))
112 })
112 })
@@ -117,12 +117,12 @@ var _ = Describe("Writer", func() {
117
117
118 BeforeEach(func() {
118 BeforeEach(func() {
119 var err error
119 var err error
120− customDir, err = ioutil.TempDir("", "oauth2-proxy-pagewriter-test")
120+ customDir, err = os.MkdirTemp("", "oauth2-proxy-pagewriter-test")
121 Expect(err).ToNot(HaveOccurred())
121 Expect(err).ToNot(HaveOccurred())
122
122
123 templateHTML := `{{ Custom Broken Template`
123 templateHTML := `{{ Custom Broken Template`
124 signInFile := filepath.Join(customDir, signInTemplateName)
124 signInFile := filepath.Join(customDir, signInTemplateName)
125− Expect(ioutil.WriteFile(signInFile, []byte(templateHTML), 0600)).To(Succeed())
125+ Expect(os.WriteFile(signInFile, []byte(templateHTML), 0600)).To(Succeed())
126
126
127 opts.TemplatesPath = customDir
127 opts.TemplatesPath = customDir
128 })
128 })
@@ -155,7 +155,7 @@ var _ = Describe("Writer", func() {
155
155
156 Expect(rw.Result().StatusCode).To(Equal(in.expectedStatus))
156 Expect(rw.Result().StatusCode).To(Equal(in.expectedStatus))
157
157
158− body, err := ioutil.ReadAll(rw.Result().Body)
158+ body, err := io.ReadAll(rw.Result().Body)
159 Expect(err).ToNot(HaveOccurred())
159 Expect(err).ToNot(HaveOccurred())
160 Expect(string(body)).To(Equal(in.expectedBody))
160 Expect(string(body)).To(Equal(in.expectedBody))
161 },
161 },
@@ -188,7 +188,7 @@ var _ = Describe("Writer", func() {
188
188
189 Expect(rw.Result().StatusCode).To(Equal(in.expectedStatus))
189 Expect(rw.Result().StatusCode).To(Equal(in.expectedStatus))
190
190
191− body, err := ioutil.ReadAll(rw.Result().Body)
191+ body, err := io.ReadAll(rw.Result().Body)
192 Expect(err).ToNot(HaveOccurred())
192 Expect(err).ToNot(HaveOccurred())
193 Expect(string(body)).To(Equal(in.expectedBody))
193 Expect(string(body)).To(Equal(in.expectedBody))
194 },
194 },
@@ -218,7 +218,7 @@ var _ = Describe("Writer", func() {
218
218
219 Expect(rw.Result().StatusCode).To(Equal(in.expectedStatus))
219 Expect(rw.Result().StatusCode).To(Equal(in.expectedStatus))
220
220
221− body, err := ioutil.ReadAll(rw.Result().Body)
221+ body, err := io.ReadAll(rw.Result().Body)
222 Expect(err).ToNot(HaveOccurred())
222 Expect(err).ToNot(HaveOccurred())
223 Expect(string(body)).To(Equal(in.expectedBody))
223 Expect(string(body)).To(Equal(in.expectedBody))
224 },
224 },
@@ -257,7 +257,7 @@ var _ = Describe("Writer", func() {
257
257
258 Expect(rw.Result().StatusCode).To(Equal(in.expectedStatus))
258 Expect(rw.Result().StatusCode).To(Equal(in.expectedStatus))
259
259
260− body, err := ioutil.ReadAll(rw.Result().Body)
260+ body, err := io.ReadAll(rw.Result().Body)
261 Expect(err).ToNot(HaveOccurred())
261 Expect(err).ToNot(HaveOccurred())
262 Expect(string(body)).To(Equal(in.expectedBody))
262 Expect(string(body)).To(Equal(in.expectedBody))
263 },
263 },
pkg/app/pagewriter/sign_in_page_test.go+5−5
@@ -4,7 +4,7 @@ import (
4 "errors"
4 "errors"
5 "fmt"
5 "fmt"
6 "html/template"
6 "html/template"
7− "io/ioutil"
7+ "io"
8 "net/http"
8 "net/http"
9 "net/http/httptest"
9 "net/http/httptest"
10 "os"
10 "os"
@@ -56,7 +56,7 @@ var _ = Describe("SignIn Page", func() {
56 recorder := httptest.NewRecorder()
56 recorder := httptest.NewRecorder()
57 signInPage.WriteSignInPage(recorder, request, "/redirect", http.StatusOK)
57 signInPage.WriteSignInPage(recorder, request, "/redirect", http.StatusOK)
58
58
59− body, err := ioutil.ReadAll(recorder.Result().Body)
59+ body, err := io.ReadAll(recorder.Result().Body)
60 Expect(err).ToNot(HaveOccurred())
60 Expect(err).ToNot(HaveOccurred())
61 Expect(string(body)).To(Equal("/prefix/ My Provider Sign In Here Custom Footer Text v0.0.0-test /redirect true Logo Data"))
61 Expect(string(body)).To(Equal("/prefix/ My Provider Sign In Here Custom Footer Text v0.0.0-test /redirect true Logo Data"))
62 })
62 })
@@ -70,7 +70,7 @@ var _ = Describe("SignIn Page", func() {
70 recorder := httptest.NewRecorder()
70 recorder := httptest.NewRecorder()
71 signInPage.WriteSignInPage(recorder, request, "/redirect", http.StatusOK)
71 signInPage.WriteSignInPage(recorder, request, "/redirect", http.StatusOK)
72
72
73− body, err := ioutil.ReadAll(recorder.Result().Body)
73+ body, err := io.ReadAll(recorder.Result().Body)
74 Expect(err).ToNot(HaveOccurred())
74 Expect(err).ToNot(HaveOccurred())
75 Expect(string(body)).To(Equal(fmt.Sprintf("Internal Server Error | %s", testRequestID)))
75 Expect(string(body)).To(Equal(fmt.Sprintf("Internal Server Error | %s", testRequestID)))
76 })
76 })
@@ -84,12 +84,12 @@ var _ = Describe("SignIn Page", func() {
84
84
85 BeforeEach(func() {
85 BeforeEach(func() {
86 var err error
86 var err error
87− customDir, err = ioutil.TempDir("", "oauth2-proxy-sign-in-page-test")
87+ customDir, err = os.MkdirTemp("", "oauth2-proxy-sign-in-page-test")
88 Expect(err).ToNot(HaveOccurred())
88 Expect(err).ToNot(HaveOccurred())
89
89
90 for _, ext := range []string{".svg", ".png", ".jpg", ".jpeg", ".gif"} {
90 for _, ext := range []string{".svg", ".png", ".jpg", ".jpeg", ".gif"} {
91 fileName := filepath.Join(customDir, fmt.Sprintf("logo%s", ext))
91 fileName := filepath.Join(customDir, fmt.Sprintf("logo%s", ext))
92− Expect(ioutil.WriteFile(fileName, []byte(fakeImageData), 0600)).To(Succeed())
92+ Expect(os.WriteFile(fileName, []byte(fakeImageData), 0600)).To(Succeed())
93 }
93 }
94 })
94 })
95
95
pkg/app/pagewriter/static_pages_test.go+6−6
@@ -3,7 +3,7 @@ package pagewriter
3import (
3import (
4 "errors"
4 "errors"
5 "html/template"
5 "html/template"
6− "io/ioutil"
6+ "io"
7 "net/http"
7 "net/http"
8 "net/http/httptest"
8 "net/http/httptest"
9 "os"
9 "os"
@@ -27,11 +27,11 @@ var _ = Describe("Static Pages", func() {
27 template: errorTmpl,
27 template: errorTmpl,
28 }
28 }
29
29
30− customDir, err = ioutil.TempDir("", "oauth2-proxy-static-pages-test")
30+ customDir, err = os.MkdirTemp("", "oauth2-proxy-static-pages-test")
31 Expect(err).ToNot(HaveOccurred())
31 Expect(err).ToNot(HaveOccurred())
32
32
33 robotsTxtFile := filepath.Join(customDir, robotsTxtName)
33 robotsTxtFile := filepath.Join(customDir, robotsTxtName)
34− Expect(ioutil.WriteFile(robotsTxtFile, []byte(customRobots), 0400)).To(Succeed())
34+ Expect(os.WriteFile(robotsTxtFile, []byte(customRobots), 0400)).To(Succeed())
35
35
36 request = httptest.NewRequest("", "http://127.0.0.1/", nil)
36 request = httptest.NewRequest("", "http://127.0.0.1/", nil)
37 request = middlewareapi.AddRequestScope(request, &middlewareapi.RequestScope{
37 request = middlewareapi.AddRequestScope(request, &middlewareapi.RequestScope{
@@ -58,7 +58,7 @@ var _ = Describe("Static Pages", func() {
58 recorder := httptest.NewRecorder()
58 recorder := httptest.NewRecorder()
59 pageWriter.WriteRobotsTxt(recorder, request)
59 pageWriter.WriteRobotsTxt(recorder, request)
60
60
61− body, err := ioutil.ReadAll(recorder.Result().Body)
61+ body, err := io.ReadAll(recorder.Result().Body)
62 Expect(err).ToNot(HaveOccurred())
62 Expect(err).ToNot(HaveOccurred())
63 Expect(string(body)).To(Equal(customRobots))
63 Expect(string(body)).To(Equal(customRobots))
64
64
@@ -81,7 +81,7 @@ var _ = Describe("Static Pages", func() {
81 recorder := httptest.NewRecorder()
81 recorder := httptest.NewRecorder()
82 pageWriter.WriteRobotsTxt(recorder, request)
82 pageWriter.WriteRobotsTxt(recorder, request)
83
83
84− body, err := ioutil.ReadAll(recorder.Result().Body)
84+ body, err := io.ReadAll(recorder.Result().Body)
85 Expect(err).ToNot(HaveOccurred())
85 Expect(err).ToNot(HaveOccurred())
86 Expect(string(body)).To(Equal(string(defaultRobotsTxt)))
86 Expect(string(body)).To(Equal(string(defaultRobotsTxt)))
87
87
@@ -94,7 +94,7 @@ var _ = Describe("Static Pages", func() {
94 }
94 }
95 pageWriter.WriteRobotsTxt(recorder, request)
95 pageWriter.WriteRobotsTxt(recorder, request)
96
96
97− body, err := ioutil.ReadAll(recorder.Result().Body)
97+ body, err := io.ReadAll(recorder.Result().Body)
98 Expect(err).ToNot(HaveOccurred())
98 Expect(err).ToNot(HaveOccurred())
99 Expect(string(body)).To(Equal(string("Internal Server Error")))
99 Expect(string(body)).To(Equal(string("Internal Server Error")))
100
100
pkg/app/pagewriter/templates_test.go+5−6
@@ -3,7 +3,6 @@ package pagewriter
3import (
3import (
4 "bytes"
4 "bytes"
5 "html/template"
5 "html/template"
6− "io/ioutil"
7 "os"
6 "os"
8 "path/filepath"
7 "path/filepath"
9
8
@@ -16,14 +15,14 @@ var _ = Describe("Templates", func() {
16
15
17 BeforeEach(func() {
16 BeforeEach(func() {
18 var err error
17 var err error
19− customDir, err = ioutil.TempDir("", "oauth2-proxy-templates-test")
18+ customDir, err = os.MkdirTemp("", "oauth2-proxy-templates-test")
20 Expect(err).ToNot(HaveOccurred())
19 Expect(err).ToNot(HaveOccurred())
21
20
22 templateHTML := `{{.TestString}} {{.TestString | ToLower}} {{.TestString | ToUpper}}`
21 templateHTML := `{{.TestString}} {{.TestString | ToLower}} {{.TestString | ToUpper}}`
23 signInFile := filepath.Join(customDir, signInTemplateName)
22 signInFile := filepath.Join(customDir, signInTemplateName)
24− Expect(ioutil.WriteFile(signInFile, []byte(templateHTML), 0600)).To(Succeed())
23+ Expect(os.WriteFile(signInFile, []byte(templateHTML), 0600)).To(Succeed())
25 errorFile := filepath.Join(customDir, errorTemplateName)
24 errorFile := filepath.Join(customDir, errorTemplateName)
26− Expect(ioutil.WriteFile(errorFile, []byte(templateHTML), 0600)).To(Succeed())
25+ Expect(os.WriteFile(errorFile, []byte(templateHTML), 0600)).To(Succeed())
27 })
26 })
28
27
29 AfterEach(func() {
28 AfterEach(func() {
@@ -162,7 +161,7 @@ var _ = Describe("Templates", func() {
162 Context("With an invalid sign_in template", func() {
161 Context("With an invalid sign_in template", func() {
163 BeforeEach(func() {
162 BeforeEach(func() {
164 signInFile := filepath.Join(customDir, signInTemplateName)
163 signInFile := filepath.Join(customDir, signInTemplateName)
165− Expect(ioutil.WriteFile(signInFile, []byte("{{"), 0600))
164+ Expect(os.WriteFile(signInFile, []byte("{{"), 0600))
166 })
165 })
167
166
168 It("Should return an error when loading templates", func() {
167 It("Should return an error when loading templates", func() {
@@ -175,7 +174,7 @@ var _ = Describe("Templates", func() {
175 Context("With an invalid error template", func() {
174 Context("With an invalid error template", func() {
176 BeforeEach(func() {
175 BeforeEach(func() {
177 errorFile := filepath.Join(customDir, errorTemplateName)
176 errorFile := filepath.Join(customDir, errorTemplateName)
178− Expect(ioutil.WriteFile(errorFile, []byte("{{"), 0600))
177+ Expect(os.WriteFile(errorFile, []byte("{{"), 0600))
179 })
178 })
180
179
181 It("Should return an error when loading templates", func() {
180 It("Should return an error when loading templates", func() {
pkg/header/header_suite_test.go+2−3
@@ -1,7 +1,6 @@
1package header
1package header
2
2
3import (
3import (
4− "io/ioutil"
5 "os"
4 "os"
6 "path"
5 "path"
7 "testing"
6 "testing"
@@ -26,9 +25,9 @@ func TestHeaderSuite(t *testing.T) {
26var _ = BeforeSuite(func() {
25var _ = BeforeSuite(func() {
27 os.Setenv("SECRET_ENV", "super-secret-env")
26 os.Setenv("SECRET_ENV", "super-secret-env")
28
27
29− dir, err := ioutil.TempDir("", "oauth2-proxy-header-suite")
28+ dir, err := os.MkdirTemp("", "oauth2-proxy-header-suite")
30 Expect(err).ToNot(HaveOccurred())
29 Expect(err).ToNot(HaveOccurred())
31− Expect(ioutil.WriteFile(path.Join(dir, "secret-file"), []byte("super-secret-file"), 0644)).To(Succeed())
30+ Expect(os.WriteFile(path.Join(dir, "secret-file"), []byte("super-secret-file"), 0644)).To(Succeed())
32 filesDir = dir
31 filesDir = dir
33})
32})
34
33
pkg/http/server.go+1−1
@@ -186,7 +186,7 @@ func (s *server) Start(ctx context.Context) error {
186// When the given context is cancelled the server will be shutdown.
186// When the given context is cancelled the server will be shutdown.
187// If any errors occur, only the first error will be returned.
187// If any errors occur, only the first error will be returned.
188func (s *server) startServer(ctx context.Context, listener net.Listener) error {
188func (s *server) startServer(ctx context.Context, listener net.Listener) error {
189− srv := &http.Server{Handler: s.handler}
189+ srv := &http.Server{Handler: s.handler, ReadHeaderTimeout: time.Minute}
190 g, groupCtx := errgroup.WithContext(ctx)
190 g, groupCtx := errgroup.WithContext(ctx)
191
191
192 g.Go(func() error {
192 g.Go(func() error {
pkg/http/server_test.go+9−9
@@ -4,7 +4,7 @@ import (
4 "context"
4 "context"
5 "errors"
5 "errors"
6 "fmt"
6 "fmt"
7− "io/ioutil"
7+ "io"
8 "net/http"
8 "net/http"
9
9
10 "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options"
10 "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options"
@@ -565,7 +565,7 @@ var _ = Describe("Server", func() {
565 Expect(err).ToNot(HaveOccurred())
565 Expect(err).ToNot(HaveOccurred())
566 Expect(resp.StatusCode).To(Equal(http.StatusOK))
566 Expect(resp.StatusCode).To(Equal(http.StatusOK))
567
567
568− body, err := ioutil.ReadAll(resp.Body)
568+ body, err := io.ReadAll(resp.Body)
569 Expect(err).ToNot(HaveOccurred())
569 Expect(err).ToNot(HaveOccurred())
570 Expect(string(body)).To(Equal(hello))
570 Expect(string(body)).To(Equal(hello))
571 })
571 })
@@ -619,7 +619,7 @@ var _ = Describe("Server", func() {
619 Expect(err).ToNot(HaveOccurred())
619 Expect(err).ToNot(HaveOccurred())
620 Expect(resp.StatusCode).To(Equal(http.StatusOK))
620 Expect(resp.StatusCode).To(Equal(http.StatusOK))
621
621
622− body, err := ioutil.ReadAll(resp.Body)
622+ body, err := io.ReadAll(resp.Body)
623 Expect(err).ToNot(HaveOccurred())
623 Expect(err).ToNot(HaveOccurred())
624 Expect(string(body)).To(Equal(hello))
624 Expect(string(body)).To(Equal(hello))
625 })
625 })
@@ -690,7 +690,7 @@ var _ = Describe("Server", func() {
690 Expect(err).ToNot(HaveOccurred())
690 Expect(err).ToNot(HaveOccurred())
691 Expect(resp.StatusCode).To(Equal(http.StatusOK))
691 Expect(resp.StatusCode).To(Equal(http.StatusOK))
692
692
693− body, err := ioutil.ReadAll(resp.Body)
693+ body, err := io.ReadAll(resp.Body)
694 Expect(err).ToNot(HaveOccurred())
694 Expect(err).ToNot(HaveOccurred())
695 Expect(string(body)).To(Equal(hello))
695 Expect(string(body)).To(Equal(hello))
696 })
696 })
@@ -705,7 +705,7 @@ var _ = Describe("Server", func() {
705 Expect(err).ToNot(HaveOccurred())
705 Expect(err).ToNot(HaveOccurred())
706 Expect(resp.StatusCode).To(Equal(http.StatusOK))
706 Expect(resp.StatusCode).To(Equal(http.StatusOK))
707
707
708− body, err := ioutil.ReadAll(resp.Body)
708+ body, err := io.ReadAll(resp.Body)
709 Expect(err).ToNot(HaveOccurred())
709 Expect(err).ToNot(HaveOccurred())
710 Expect(string(body)).To(Equal(hello))
710 Expect(string(body)).To(Equal(hello))
711 })
711 })
@@ -761,7 +761,7 @@ var _ = Describe("Server", func() {
761 Expect(err).ToNot(HaveOccurred())
761 Expect(err).ToNot(HaveOccurred())
762 Expect(resp.StatusCode).To(Equal(http.StatusOK))
762 Expect(resp.StatusCode).To(Equal(http.StatusOK))
763
763
764− body, err := ioutil.ReadAll(resp.Body)
764+ body, err := io.ReadAll(resp.Body)
765 Expect(err).ToNot(HaveOccurred())
765 Expect(err).ToNot(HaveOccurred())
766 Expect(string(body)).To(Equal(hello))
766 Expect(string(body)).To(Equal(hello))
767 })
767 })
@@ -815,7 +815,7 @@ var _ = Describe("Server", func() {
815 Expect(err).ToNot(HaveOccurred())
815 Expect(err).ToNot(HaveOccurred())
816 Expect(resp.StatusCode).To(Equal(http.StatusOK))
816 Expect(resp.StatusCode).To(Equal(http.StatusOK))
817
817
818− body, err := ioutil.ReadAll(resp.Body)
818+ body, err := io.ReadAll(resp.Body)
819 Expect(err).ToNot(HaveOccurred())
819 Expect(err).ToNot(HaveOccurred())
820 Expect(string(body)).To(Equal(hello))
820 Expect(string(body)).To(Equal(hello))
821 })
821 })
@@ -886,7 +886,7 @@ var _ = Describe("Server", func() {
886 Expect(err).ToNot(HaveOccurred())
886 Expect(err).ToNot(HaveOccurred())
887 Expect(resp.StatusCode).To(Equal(http.StatusOK))
887 Expect(resp.StatusCode).To(Equal(http.StatusOK))
888
888
889− body, err := ioutil.ReadAll(resp.Body)
889+ body, err := io.ReadAll(resp.Body)
890 Expect(err).ToNot(HaveOccurred())
890 Expect(err).ToNot(HaveOccurred())
891 Expect(string(body)).To(Equal(hello))
891 Expect(string(body)).To(Equal(hello))
892 })
892 })
@@ -901,7 +901,7 @@ var _ = Describe("Server", func() {
901 Expect(err).ToNot(HaveOccurred())
901 Expect(err).ToNot(HaveOccurred())
902 Expect(resp.StatusCode).To(Equal(http.StatusOK))
902 Expect(resp.StatusCode).To(Equal(http.StatusOK))
903
903
904− body, err := ioutil.ReadAll(resp.Body)
904+ body, err := io.ReadAll(resp.Body)
905 Expect(err).ToNot(HaveOccurred())
905 Expect(err).ToNot(HaveOccurred())
906 Expect(string(body)).To(Equal(hello))
906 Expect(string(body)).To(Equal(hello))
907 })
907 })
pkg/providers/util/claim_extractor.go+1−1
@@ -98,7 +98,7 @@ func (c *claimExtractor) loadProfileClaims() (*simplejson.Json, error) {
98 WithContext(c.ctx).
98 WithContext(c.ctx).
99 WithHeaders(c.requestHeaders).
99 WithHeaders(c.requestHeaders).
100 Do().
100 Do().
101− UnmarshalJSON()
101+ UnmarshalSimpleJSON()
102 if err != nil {
102 if err != nil {
103 return nil, fmt.Errorf("error making request to profile URL: %v", err)
103 return nil, fmt.Errorf("error making request to profile URL: %v", err)
104 }
104 }
pkg/requests/builder.go+1−2
@@ -4,7 +4,6 @@ import (
4 "context"
4 "context"
5 "fmt"
5 "fmt"
6 "io"
6 "io"
7− "io/ioutil"
8 "net/http"
7 "net/http"
9)
8)
10
9
@@ -107,7 +106,7 @@ func (r *builder) do() Result {
107 }
106 }
108
107
109 defer resp.Body.Close()
108 defer resp.Body.Close()
110− body, err := ioutil.ReadAll(resp.Body)
109+ body, err := io.ReadAll(resp.Body)
111 if err != nil {
110 if err != nil {
112 r.result = &result{err: fmt.Errorf("error reading response body: %v", err)}
111 r.result = &result{err: fmt.Errorf("error reading response body: %v", err)}
113 return r.result
112 return r.result
pkg/requests/builder_test.go+3−3
@@ -285,7 +285,7 @@ func assertSuccessfulRequest(builder func() Builder, expectedRequest testHTTPReq
285
285
286 BeforeEach(func() {
286 BeforeEach(func() {
287 var err error
287 var err error
288− response, err = builder().Do().UnmarshalJSON()
288+ response, err = builder().Do().UnmarshalSimpleJSON()
289 Expect(err).ToNot(HaveOccurred())
289 Expect(err).ToNot(HaveOccurred())
290 })
290 })
291
291
@@ -340,7 +340,7 @@ func assertRequestError(builder func() Builder, errorMessage string) {
340
340
341 Context("UnmarshalJSON", func() {
341 Context("UnmarshalJSON", func() {
342 It("returns an error", func() {
342 It("returns an error", func() {
343− resp, err := builder().Do().UnmarshalJSON()
343+ resp, err := builder().Do().UnmarshalSimpleJSON()
344 Expect(err).To(MatchError(ContainSubstring(errorMessage)))
344 Expect(err).To(MatchError(ContainSubstring(errorMessage)))
345 Expect(resp).To(BeNil())
345 Expect(resp).To(BeNil())
346 })
346 })
@@ -368,7 +368,7 @@ func assertJSONError(builder func() Builder, errorMessage string) {
368
368
369 Context("UnmarshalJSON", func() {
369 Context("UnmarshalJSON", func() {
370 It("returns an error", func() {
370 It("returns an error", func() {
371− resp, err := builder().Do().UnmarshalJSON()
371+ resp, err := builder().Do().UnmarshalSimpleJSON()
372 Expect(err).To(MatchError(ContainSubstring(errorMessage)))
372 Expect(err).To(MatchError(ContainSubstring(errorMessage)))
373 Expect(resp).To(BeNil())
373 Expect(resp).To(BeNil())
374 })
374 })
pkg/requests/requests_suite_test.go+2−2
@@ -3,7 +3,7 @@ package requests
3import (
3import (
4 "encoding/json"
4 "encoding/json"
5 "fmt"
5 "fmt"
6− "io/ioutil"
6+ "io"
7 "log"
7 "log"
8 "net/http"
8 "net/http"
9 "net/http/httptest"
9 "net/http/httptest"
@@ -82,7 +82,7 @@ func toTestHTTPRequest(req *http.Request) (testHTTPRequest, error) {
82 requestBody := []byte{}
82 requestBody := []byte{}
83 if req.Body != http.NoBody {
83 if req.Body != http.NoBody {
84 var err error
84 var err error
85− requestBody, err = ioutil.ReadAll(req.Body)
85+ requestBody, err = io.ReadAll(req.Body)
86 if err != nil {
86 if err != nil {
87 return testHTTPRequest{}, err
87 return testHTTPRequest{}, err
88 }
88 }
pkg/requests/result.go+3−3
@@ -15,7 +15,7 @@ type Result interface {
15 Headers() http.Header
15 Headers() http.Header
16 Body() []byte
16 Body() []byte
17 UnmarshalInto(interface{}) error
17 UnmarshalInto(interface{}) error
18− UnmarshalJSON() (*simplejson.Json, error)
18+ UnmarshalSimpleJSON() (*simplejson.Json, error)
19}
19}
20
20
21type result struct {
21type result struct {
@@ -66,10 +66,10 @@ func (r *result) UnmarshalInto(into interface{}) error {
66 return nil
66 return nil
67}
67}
68
68
69−// UnmarshalJSON performs the request and attempts to unmarshal the response into a
69+// UnmarshalSimpleJSON performs the request and attempts to unmarshal the response into a
70// simplejson.Json. The response body is assume to be JSON.
70// simplejson.Json. The response body is assume to be JSON.
71// The response must have a 200 status otherwise an error will be returned.
71// The response must have a 200 status otherwise an error will be returned.
72−func (r *result) UnmarshalJSON() (*simplejson.Json, error) {
72+func (r *result) UnmarshalSimpleJSON() (*simplejson.Json, error) {
73 body, err := r.getBodyForUnmarshal()
73 body, err := r.getBodyForUnmarshal()
74 if err != nil {
74 if err != nil {
75 return nil, err
75 return nil, err
pkg/requests/result_test.go+1−1
@@ -198,7 +198,7 @@ var _ = Describe("Result suite", func() {
198
198
199 DescribeTable("with a result",
199 DescribeTable("with a result",
200 func(in unmarshalJSONTableInput) {
200 func(in unmarshalJSONTableInput) {
201− j, err := in.result.UnmarshalJSON()
201+ j, err := in.result.UnmarshalSimpleJSON()
202 if in.expectedErr != nil {
202 if in.expectedErr != nil {
203 Expect(err).To(MatchError(in.expectedErr))
203 Expect(err).To(MatchError(in.expectedErr))
204 Expect(j).To(BeNil())
204 Expect(j).To(BeNil())
pkg/sessions/redis/redis_store.go+2−2
@@ -5,7 +5,7 @@ import (
5 "crypto/tls"
5 "crypto/tls"
6 "crypto/x509"
6 "crypto/x509"
7 "fmt"
7 "fmt"
8− "io/ioutil"
8+ "os"
9 "time"
9 "time"
10
10
11 "github.com/go-redis/redis/v8"
11 "github.com/go-redis/redis/v8"
@@ -170,7 +170,7 @@ func setupTLSConfig(opts options.RedisStoreOptions, opt *redis.Options) error {
170 if rootCAs == nil {
170 if rootCAs == nil {
171 rootCAs = x509.NewCertPool()
171 rootCAs = x509.NewCertPool()
172 }
172 }
173− certs, err := ioutil.ReadFile(opts.CAPath)
173+ certs, err := os.ReadFile(opts.CAPath)
174 if err != nil {
174 if err != nil {
175 return fmt.Errorf("failed to load %q, %v", opts.CAPath, err)
175 return fmt.Errorf("failed to load %q, %v", opts.CAPath, err)
176 }
176 }
pkg/upstream/upstream_suite_test.go+6−6
@@ -3,7 +3,7 @@ package upstream
3import (
3import (
4 "encoding/json"
4 "encoding/json"
5 "fmt"
5 "fmt"
6− "io/ioutil"
6+ "io"
7 "log"
7 "log"
8 "net/http"
8 "net/http"
9 "net/http/httptest"
9 "net/http/httptest"
@@ -35,12 +35,12 @@ func TestUpstreamSuite(t *testing.T) {
35
35
36var _ = BeforeSuite(func() {
36var _ = BeforeSuite(func() {
37 // Set up files for serving via file servers
37 // Set up files for serving via file servers
38− dir, err := ioutil.TempDir("", "oauth2-proxy-upstream-suite")
38+ dir, err := os.MkdirTemp("", "oauth2-proxy-upstream-suite")
39 Expect(err).ToNot(HaveOccurred())
39 Expect(err).ToNot(HaveOccurred())
40− Expect(ioutil.WriteFile(path.Join(dir, "foo"), []byte("foo"), 0644)).To(Succeed())
40+ Expect(os.WriteFile(path.Join(dir, "foo"), []byte("foo"), 0644)).To(Succeed())
41− Expect(ioutil.WriteFile(path.Join(dir, "bar"), []byte("bar"), 0644)).To(Succeed())
41+ Expect(os.WriteFile(path.Join(dir, "bar"), []byte("bar"), 0644)).To(Succeed())
42 Expect(os.Mkdir(path.Join(dir, "subdir"), os.ModePerm)).To(Succeed())
42 Expect(os.Mkdir(path.Join(dir, "subdir"), os.ModePerm)).To(Succeed())
43− Expect(ioutil.WriteFile(path.Join(dir, "subdir", "baz"), []byte("baz"), 0644)).To(Succeed())
43+ Expect(os.WriteFile(path.Join(dir, "subdir", "baz"), []byte("baz"), 0644)).To(Succeed())
44 filesDir = dir
44 filesDir = dir
45
45
46 // Set up a webserver that reflects requests
46 // Set up a webserver that reflects requests
@@ -148,7 +148,7 @@ func toTestHTTPRequest(req *http.Request) (testHTTPRequest, error) {
148 requestBody := []byte{}
148 requestBody := []byte{}
149 if req.Body != http.NoBody {
149 if req.Body != http.NoBody {
150 var err error
150 var err error
151− requestBody, err = ioutil.ReadAll(req.Body)
151+ requestBody, err = io.ReadAll(req.Body)
152 if err != nil {
152 if err != nil {
153 return testHTTPRequest{}, err
153 return testHTTPRequest{}, err
154 }
154 }
pkg/util/util.go+2−2
@@ -6,10 +6,10 @@ import (
6 "crypto/x509"
6 "crypto/x509"
7 "crypto/x509/pkix"
7 "crypto/x509/pkix"
8 "fmt"
8 "fmt"
9− "io/ioutil"
10 "math/big"
9 "math/big"
11 "net"
10 "net"
12 "net/url"
11 "net/url"
12+ "os"
13 "strings"
13 "strings"
14 "time"
14 "time"
15)
15)
@@ -21,7 +21,7 @@ func GetCertPool(paths []string) (*x509.CertPool, error) {
21 pool := x509.NewCertPool()
21 pool := x509.NewCertPool()
22 for _, path := range paths {
22 for _, path := range paths {
23 // Cert paths are a configurable option
23 // Cert paths are a configurable option
24− data, err := ioutil.ReadFile(path) // #nosec G304
24+ data, err := os.ReadFile(path) // #nosec G304
25 if err != nil {
25 if err != nil {
26 return nil, fmt.Errorf("certificate authority file (%s) could not be read - %s", path, err)
26 return nil, fmt.Errorf("certificate authority file (%s) could not be read - %s", path, err)
27 }
27 }
pkg/util/util_test.go+2−3
@@ -3,7 +3,6 @@ package util
3import (
3import (
4 "crypto/x509"
4 "crypto/x509"
5 "encoding/pem"
5 "encoding/pem"
6− "io/ioutil"
7 "os"
6 "os"
8 "testing"
7 "testing"
9
8
@@ -183,7 +182,7 @@ WrW4JMzLaGDtoHxRNNfo8E7fGkQ=
183)
182)
184
183
185func makeTestCertFile(t *testing.T, pem, dir string) *os.File {
184func makeTestCertFile(t *testing.T, pem, dir string) *os.File {
186− file, err := ioutil.TempFile(dir, "test-certfile")
185+ file, err := os.CreateTemp(dir, "test-certfile")
187 assert.NoError(t, err)
186 assert.NoError(t, err)
188 _, err = file.Write([]byte(pem))
187 _, err = file.Write([]byte(pem))
189 assert.NoError(t, err)
188 assert.NoError(t, err)
@@ -196,7 +195,7 @@ func TestGetCertPool_NoRoots(t *testing.T) {
196}
195}
197
196
198func TestGetCertPool(t *testing.T) {
197func TestGetCertPool(t *testing.T) {
199− tempDir, err := ioutil.TempDir("", "certtest")
198+ tempDir, err := os.MkdirTemp("", "certtest")
200 assert.NoError(t, err)
199 assert.NoError(t, err)
201 defer func(path string) {
200 defer func(path string) {
202 rerr := os.RemoveAll(path)
201 rerr := os.RemoveAll(path)
pkg/validation/common_test.go+1−2
@@ -1,7 +1,6 @@
1package validation
1package validation
2
2
3import (
3import (
4− "io/ioutil"
5 "os"
4 "os"
6
5
7 "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options"
6 "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options"
@@ -18,7 +17,7 @@ var _ = Describe("Common", func() {
18 BeforeEach(func() {
17 BeforeEach(func() {
19 validSecretSourceValue = []byte("This is a secret source value")
18 validSecretSourceValue = []byte("This is a secret source value")
20 Expect(os.Setenv(validSecretSourceEnv, "This is a secret source env")).To(Succeed())
19 Expect(os.Setenv(validSecretSourceEnv, "This is a secret source env")).To(Succeed())
21− tmp, err := ioutil.TempFile("", "oauth2-proxy-secret-source-test")
20+ tmp, err := os.CreateTemp("", "oauth2-proxy-secret-source-test")
22 Expect(err).ToNot(HaveOccurred())
21 Expect(err).ToNot(HaveOccurred())
23 defer tmp.Close()
22 defer tmp.Close()
24
23
pkg/validation/options_test.go+1−2
@@ -2,7 +2,6 @@ package validation
2
2
3import (
3import (
4 "crypto"
4 "crypto"
5− "io/ioutil"
6 "net/url"
5 "net/url"
7 "os"
6 "os"
8 "strings"
7 "strings"
@@ -205,7 +204,7 @@ func TestRealClientIPHeader(t *testing.T) {
205}
204}
206
205
207func TestProviderCAFilesError(t *testing.T) {
206func TestProviderCAFilesError(t *testing.T) {
208− file, err := ioutil.TempFile("", "absent.*.crt")
207+ file, err := os.CreateTemp("", "absent.*.crt")
209 assert.NoError(t, err)
208 assert.NoError(t, err)
210 assert.NoError(t, file.Close())
209 assert.NoError(t, file.Close())
211 assert.NoError(t, os.Remove(file.Name()))
210 assert.NoError(t, os.Remove(file.Name()))
pkg/validation/providers.go+1−2
@@ -2,7 +2,6 @@ package validation
2
2
3import (
3import (
4 "fmt"
4 "fmt"
5− "io/ioutil"
6 "os"
5 "os"
7
6
8 "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options"
7 "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options"
@@ -53,7 +52,7 @@ func validateProvider(provider options.Provider, providerIDs map[string]struct{}
53 msgs = append(msgs, "missing setting: client-secret or client-secret-file")
52 msgs = append(msgs, "missing setting: client-secret or client-secret-file")
54 }
53 }
55 if provider.ClientSecret == "" && provider.ClientSecretFile != "" {
54 if provider.ClientSecret == "" && provider.ClientSecretFile != "" {
56− _, err := ioutil.ReadFile(provider.ClientSecretFile)
55+ _, err := os.ReadFile(provider.ClientSecretFile)
57 if err != nil {
56 if err != nil {
58 msgs = append(msgs, "could not read client secret file: "+provider.ClientSecretFile)
57 msgs = append(msgs, "could not read client secret file: "+provider.ClientSecretFile)
59 }
58 }
pkg/watcher/watcher.go+2−2
@@ -44,8 +44,8 @@ func WatchFileForUpdates(filename string, done <-chan bool, action func()) error
44
44
45// Filter file operations based on the events sent by the watcher.
45// Filter file operations based on the events sent by the watcher.
46// Execute the action() function when the following conditions are met:
46// Execute the action() function when the following conditions are met:
47−// - the real path of the file was changed (Kubernetes ConfigMap/Secret)
47+// - the real path of the file was changed (Kubernetes ConfigMap/Secret)
48−// - the file is modified or created
48+// - the file is modified or created
49func filterEvent(watcher *fsnotify.Watcher, event fsnotify.Event, filename string, action func()) {
49func filterEvent(watcher *fsnotify.Watcher, event fsnotify.Event, filename string, action func()) {
50 switch filepath.Clean(event.Name) == filename {
50 switch filepath.Clean(event.Name) == filename {
51 // In Kubernetes the file path is a symlink, so we should take action
51 // In Kubernetes the file path is a symlink, so we should take action
providers/azure.go+1−1
@@ -347,7 +347,7 @@ func (p *AzureProvider) getEmailFromProfileAPI(ctx context.Context, accessToken
347 WithContext(ctx).
347 WithContext(ctx).
348 WithHeaders(makeAzureHeader(accessToken)).
348 WithHeaders(makeAzureHeader(accessToken)).
349 Do().
349 Do().
350− UnmarshalJSON()
350+ UnmarshalSimpleJSON()
351 if err != nil {
351 if err != nil {
352 return "", err
352 return "", err
353 }
353 }
providers/digitalocean.go+1−1
@@ -72,7 +72,7 @@ func (p *DigitalOceanProvider) GetEmailAddress(ctx context.Context, s *sessions.
72 WithContext(ctx).
72 WithContext(ctx).
73 WithHeaders(makeOIDCHeader(s.AccessToken)).
73 WithHeaders(makeOIDCHeader(s.AccessToken)).
74 Do().
74 Do().
75− UnmarshalJSON()
75+ UnmarshalSimpleJSON()
76 if err != nil {
76 if err != nil {
77 return "", err
77 return "", err
78 }
78 }
providers/google.go+1−2
@@ -8,7 +8,6 @@ import (
8 "errors"
8 "errors"
9 "fmt"
9 "fmt"
10 "io"
10 "io"
11− "io/ioutil"
12 "net/url"
11 "net/url"
13 "os"
12 "os"
14 "strings"
13 "strings"
@@ -231,7 +230,7 @@ func (p *GoogleProvider) setGroupRestriction(groups []string, adminEmail string,
231}
230}
232
231
233func getAdminService(adminEmail string, credentialsReader io.Reader) *admin.Service {
232func getAdminService(adminEmail string, credentialsReader io.Reader) *admin.Service {
234− data, err := ioutil.ReadAll(credentialsReader)
233+ data, err := io.ReadAll(credentialsReader)
235 if err != nil {
234 if err != nil {
236 logger.Fatal("can't read Google credentials file:", err)
235 logger.Fatal("can't read Google credentials file:", err)
237 }
236 }
providers/google_test.go−1
@@ -166,7 +166,6 @@ func TestGoogleProviderGroupValidator(t *testing.T) {
166 }
166 }
167}
167}
168
168
169−//
170func TestGoogleProviderGetEmailAddressInvalidEncoding(t *testing.T) {
169func TestGoogleProviderGetEmailAddressInvalidEncoding(t *testing.T) {
171 p := newGoogleProvider(t)
170 p := newGoogleProvider(t)
172 body, err := json.Marshal(redeemResponse{
171 body, err := json.Marshal(redeemResponse{
providers/keycloak.go+1−1
@@ -77,7 +77,7 @@ func (p *KeycloakProvider) EnrichSession(ctx context.Context, s *sessions.Sessio
77 WithContext(ctx).
77 WithContext(ctx).
78 SetHeader("Authorization", "Bearer "+s.AccessToken).
78 SetHeader("Authorization", "Bearer "+s.AccessToken).
79 Do().
79 Do().
80− UnmarshalJSON()
80+ UnmarshalSimpleJSON()
81 if err != nil {
81 if err != nil {
82 logger.Errorf("failed making request %v", err)
82 logger.Errorf("failed making request %v", err)
83 return err
83 return err
providers/keycloak_oidc.go+15−14
@@ -124,20 +124,21 @@ func (p *KeycloakOIDCProvider) getAccessClaims(ctx context.Context, s *sessions.
124// the format `client:role`.
124// the format `client:role`.
125//
125//
126// ResourceAccess format:
126// ResourceAccess format:
127+//
127−// "resource_access": {
128+// "resource_access": {
128−// "clientA": {
129+// "clientA": {
129−// "roles": [
130+// "roles": [
130−// "roleA"
131+// "roleA"
131−// ]
132+// ]
132−// },
133+// },
133−// "clientB": {
134+// "clientB": {
134−// "roles": [
135+// "roles": [
135−// "roleA",
136+// "roleA",
136−// "roleB",
137+// "roleB",
137−// "roleC"
138+// "roleC"
138−// ]
139+// ]
139−// }
140+// }
140−// }
141+// }
141func getClientRoles(claims *accessClaims) []string {
142func getClientRoles(claims *accessClaims) []string {
142 var clientRoles []string
143 var clientRoles []string
143 for clientName, access := range claims.ResourceAccess {
144 for clientName, access := range claims.ResourceAccess {
providers/linkedin.go+1−1
@@ -90,7 +90,7 @@ func (p *LinkedInProvider) GetEmailAddress(ctx context.Context, s *sessions.Sess
90 WithContext(ctx).
90 WithContext(ctx).
91 WithHeaders(makeLinkedInHeader(s.AccessToken)).
91 WithHeaders(makeLinkedInHeader(s.AccessToken)).
92 Do().
92 Do().
93− UnmarshalJSON()
93+ UnmarshalSimpleJSON()
94 if err != nil {
94 if err != nil {
95 return "", err
95 return "", err
96 }
96 }
providers/logingov.go+2−2
@@ -7,9 +7,9 @@ import (
7 "crypto/rsa"
7 "crypto/rsa"
8 "errors"
8 "errors"
9 "fmt"
9 "fmt"
10− "io/ioutil"
11 "math/big"
10 "math/big"
12 "net/url"
11 "net/url"
12+ "os"
13 "time"
13 "time"
14
14
15 "github.com/golang-jwt/jwt"
15 "github.com/golang-jwt/jwt"
@@ -123,7 +123,7 @@ func (p *LoginGovProvider) configure(opts options.LoginGovOptions) error {
123 p.JWTKey = signKey
123 p.JWTKey = signKey
124 case opts.JWTKeyFile != "":
124 case opts.JWTKeyFile != "":
125 // The JWT key is in the filesystem
125 // The JWT key is in the filesystem
126− keyData, err := ioutil.ReadFile(opts.JWTKeyFile)
126+ keyData, err := os.ReadFile(opts.JWTKeyFile)
127 if err != nil {
127 if err != nil {
128 return fmt.Errorf("could not read key file: %v", opts.JWTKeyFile)
128 return fmt.Errorf("could not read key file: %v", opts.JWTKeyFile)
129 }
129 }
providers/nextcloud.go+1−1
@@ -44,7 +44,7 @@ func (p *NextcloudProvider) EnrichSession(ctx context.Context, s *sessions.Sessi
44 WithContext(ctx).
44 WithContext(ctx).
45 SetHeader("Authorization", "Bearer "+s.AccessToken).
45 SetHeader("Authorization", "Bearer "+s.AccessToken).
46 Do().
46 Do().
47− UnmarshalJSON()
47+ UnmarshalSimpleJSON()
48 if err != nil {
48 if err != nil {
49 logger.Errorf("failed making request %v", err)
49 logger.Errorf("failed making request %v", err)
50 return err
50 return err
providers/provider_data.go+2−2
@@ -4,9 +4,9 @@ import (
4 "context"
4 "context"
5 "errors"
5 "errors"
6 "fmt"
6 "fmt"
7− "io/ioutil"
8 "net/http"
7 "net/http"
9 "net/url"
8 "net/url"
9+ "os"
10 "regexp"
10 "regexp"
11 "strings"
11 "strings"
12
12
@@ -67,7 +67,7 @@ func (p *ProviderData) GetClientSecret() (clientSecret string, err error) {
67 }
67 }
68
68
69 // Getting ClientSecret can fail in runtime so we need to report it without returning the file name to the user
69 // Getting ClientSecret can fail in runtime so we need to report it without returning the file name to the user
70− fileClientSecret, err := ioutil.ReadFile(p.ClientSecretFile)
70+ fileClientSecret, err := os.ReadFile(p.ClientSecretFile)
71 if err != nil {
71 if err != nil {
72 logger.Errorf("error reading client secret file %s: %s", p.ClientSecretFile, err)
72 logger.Errorf("error reading client secret file %s: %s", p.ClientSecretFile, err)
73 return "", errors.New("could not read client secret file")
73 return "", errors.New("could not read client secret file")
providers/providers_test.go+1−2
@@ -1,7 +1,6 @@
1package providers
1package providers
2
2
3import (
3import (
4− "io/ioutil"
5 "os"
4 "os"
6 "testing"
5 "testing"
7
6
@@ -43,7 +42,7 @@ func TestClientSecretFileOptionFails(t *testing.T) {
43func TestClientSecretFileOption(t *testing.T) {
42func TestClientSecretFileOption(t *testing.T) {
44 g := NewWithT(t)
43 g := NewWithT(t)
45
44
46− f, err := ioutil.TempFile("", "client_secret_temp_file_")
45+ f, err := os.CreateTemp("", "client_secret_temp_file_")
47 g.Expect(err).ToNot(HaveOccurred())
46 g.Expect(err).ToNot(HaveOccurred())
48
47
49 clientSecretFileName := f.Name()
48 clientSecretFileName := f.Name()
validator_test.go+1−2
@@ -1,7 +1,6 @@
1package main
1package main
2
2
3import (
3import (
4− "io/ioutil"
5 "os"
4 "os"
6 "strings"
5 "strings"
7 "testing"
6 "testing"
@@ -18,7 +17,7 @@ type ValidatorTest struct {
18func NewValidatorTest(t *testing.T) *ValidatorTest {
17func NewValidatorTest(t *testing.T) *ValidatorTest {
19 vt := &ValidatorTest{}
18 vt := &ValidatorTest{}
20 var err error
19 var err error
21− f, err := ioutil.TempFile("", "test_auth_emails_")
20+ f, err := os.CreateTemp("", "test_auth_emails_")
22 if err != nil {
21 if err != nil {
23 t.Fatalf("failed to create temp file: %v", err)
22 t.Fatalf("failed to create temp file: %v", err)
24 }
23 }