From 022caf39b441910c206f9d3500307cb3c0dd1cc4 Mon Sep 17 00:00:00 2001 From: shankar0123 Date: Sun, 3 May 2026 21:32:55 +0000 Subject: [PATCH] =?UTF-8?q?ci(googlecas):=20fix=20QF1002=20staticcheck=20?= =?UTF-8?q?=E2=80=94=20tagged=20switch=20on=20r.URL.Path?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CI failure on commit a2a59a8 (run #423): internal/connector/issuer/googlecas/googlecas_failure_test.go:189:3: QF1002: could use tagged switch on r.URL.Path (staticcheck) The OAuth2 token-refresh test handler had two cases — `r.URL.Path == "/token"` and `default` — both equality-against-r.URL.Path. Stati- ccheck's QF1002 rule wants this expressed as a tagged switch: switch r.URL.Path { case "/token": ... default: ... } The other four switches in the same file are mixed equality + Contains (`case r.URL.Path == "/token":` + `case strings.Contains(r.URL.Path, "/certificates"):`) — those are not tag-able and stay on `switch { case ... }`. Only the OAuth2 test handler had the single- equality-case pattern QF1002 fires on. Test-only commit. No production code change. Verified locally: - gofmt clean. - go test -short -count=1 ./internal/connector/issuer/googlecas/... green (5 failure tests + 14 happy-path subtests + 4 stub tests). --- .../connector/issuer/googlecas/googlecas_failure_test.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/connector/issuer/googlecas/googlecas_failure_test.go b/internal/connector/issuer/googlecas/googlecas_failure_test.go index f0e3efe..9093882 100644 --- a/internal/connector/issuer/googlecas/googlecas_failure_test.go +++ b/internal/connector/issuer/googlecas/googlecas_failure_test.go @@ -186,8 +186,12 @@ func TestGoogleCAS_Issue_OAuth2TokenRefreshFailure_DistinguishedFromCAError(t *t credPath := createTestCredentialsFile(t) srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - switch { - case r.URL.Path == "/token": + // Tagged switch on r.URL.Path keeps staticcheck QF1002 happy + // (only equality cases against a single field). The other + // failure tests use mixed equality + strings.Contains so they + // stay on `switch { case ... }`. + switch r.URL.Path { + case "/token": w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusUnauthorized) _, _ = w.Write([]byte(`{"error":"invalid_grant","error_description":"Invalid JWT Signature."}`))