1
0
mirror of https://github.com/oauth2-proxy/oauth2-proxy.git synced 2025-06-21 00:29:44 +02:00

chore(lint): fix staticcheck issues (#3061)

* chores: fix staticcheck QF1012

Fix use of fmt.Sprintf when writing to a writer.
https://staticcheck.dev/docs/checks/#QF1012
https://github.com/oauth2-proxy/oauth2-proxy/issues/3060

* chores: fix staticcheck QF1003

Use switch instead of multiple if/else.
https://staticcheck.dev/docs/checks/#QF1003
https://github.com/oauth2-proxy/oauth2-proxy/issues/3060

* chores: exclude staticcheck QF1008 for now

We aim to migrate golangci-lint to v2
Let's disable QF1008 (Omit embedded fields from selector expression)
for now.
https://staticcheck.dev/docs/checks/#QF1008

* chores: fix golangci config: run.deadline -> timeout

Rename config option to match v1 documentation: deadline -> timeout.
https://golangci.github.io/legacy-v1-doc/usage/configuration/#run-configuration

This error has been spotted by golangci-lint v2 migration tool.

* chores: fix staticcheck QF1012
This commit is contained in:
Olivier Mengué
2025-05-26 12:29:34 +02:00
committed by GitHub
parent 09f6252ebf
commit 1225d611e9
4 changed files with 17 additions and 12 deletions

View File

@ -237,30 +237,31 @@ func TestGoogleProviderGetEmailAddressEmailMissing(t *testing.T) {
func TestGoogleProvider_userInGroup(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "/admin/directory/v1/groups/group@example.com/hasMember/member-in-domain@example.com" {
switch r.URL.Path {
case "/admin/directory/v1/groups/group@example.com/hasMember/member-in-domain@example.com":
fmt.Fprintln(w, `{"isMember":true}`)
} else if r.URL.Path == "/admin/directory/v1/groups/group@example.com/hasMember/non-member-in-domain@example.com" {
case "/admin/directory/v1/groups/group@example.com/hasMember/non-member-in-domain@example.com":
fmt.Fprintln(w, `{"isMember":false}`)
} else if r.URL.Path == "/admin/directory/v1/groups/group@example.com/hasMember/member-out-of-domain@otherexample.com" {
case "/admin/directory/v1/groups/group@example.com/hasMember/member-out-of-domain@otherexample.com":
http.Error(
w,
`{"error":{"errors":[{"domain":"global","reason":"invalid","message":"Invalid Input: memberKey"}],"code":400,"message":"Invalid Input: memberKey"}}`,
http.StatusBadRequest,
)
} else if r.URL.Path == "/admin/directory/v1/groups/group@example.com/hasMember/non-member-out-of-domain@otherexample.com" {
case "/admin/directory/v1/groups/group@example.com/hasMember/non-member-out-of-domain@otherexample.com":
http.Error(
w,
`{"error":{"errors":[{"domain":"global","reason":"invalid","message":"Invalid Input: memberKey"}],"code":400,"message":"Invalid Input: memberKey"}}`,
http.StatusBadRequest,
)
} else if r.URL.Path == "/admin/directory/v1/groups/group@example.com/members/non-member-out-of-domain@otherexample.com" {
case "/admin/directory/v1/groups/group@example.com/members/non-member-out-of-domain@otherexample.com":
// note that the client currently doesn't care what this response text or code is - any error here results in failure to match the group
http.Error(
w,
`{"kind":"admin#directory#member","etag":"12345","id":"1234567890","email":"member-out-of-domain@otherexample.com","role":"MEMBER","type":"USER","status":"ACTIVE","delivery_settings":"ALL_MAIL"}`,
http.StatusNotFound,
)
} else if r.URL.Path == "/admin/directory/v1/groups/group@example.com/members/member-out-of-domain@otherexample.com" {
case "/admin/directory/v1/groups/group@example.com/members/member-out-of-domain@otherexample.com":
fmt.Fprintln(w,
`{"kind":"admin#directory#member","etag":"12345","id":"1234567890","email":"member-out-of-domain@otherexample.com","role":"MEMBER","type":"USER","status":"ACTIVE","delivery_settings":"ALL_MAIL"}`,
)