mirror of
https://github.com/shankar0123/certctl.git
synced 2026-06-07 16:21:30 +00:00
ci(googlecas): fix QF1002 staticcheck — tagged switch on r.URL.Path
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).
This commit is contained in:
@@ -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."}`))
|
||||
|
||||
Reference in New Issue
Block a user