fix: use tagged switch statements to satisfy staticcheck QF1002

Convert `switch { case r.URL.Path == ... }` to `switch r.URL.Path { ... }`
in Vault and DigiCert connector tests to pass golangci-lint CI.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
shankar0123
2026-03-30 17:25:11 -04:00
parent 6375909591
commit 648e2f7ab1
2 changed files with 14 additions and 14 deletions
@@ -241,11 +241,11 @@ func TestDigiCertConnector(t *testing.T) {
pemBundle := testCertPEM + testChainPEM
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch {
case r.URL.Path == "/order/certificate/99001":
switch r.URL.Path {
case "/order/certificate/99001":
w.WriteHeader(http.StatusOK)
w.Write([]byte(`{"id":99001,"status":"issued","certificate":{"id":88001,"common_name":"app.example.com"}}`))
case r.URL.Path == "/certificate/88001/download/format/pem_all":
case "/certificate/88001/download/format/pem_all":
w.WriteHeader(http.StatusOK)
w.Write([]byte(pemBundle))
default:
@@ -431,11 +431,11 @@ func TestDigiCertConnector(t *testing.T) {
t.Run("GetOrderStatus_DownloadError", func(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch {
case r.URL.Path == "/order/certificate/99004":
switch r.URL.Path {
case "/order/certificate/99004":
w.WriteHeader(http.StatusOK)
w.Write([]byte(`{"id":99004,"status":"issued","certificate":{"id":88004}}`))
case r.URL.Path == "/certificate/88004/download/format/pem_all":
case "/certificate/88004/download/format/pem_all":
w.WriteHeader(http.StatusInternalServerError)
w.Write([]byte(`{"errors":["internal server error"]}`))
default:
@@ -317,10 +317,10 @@ func TestVaultConnector(t *testing.T) {
t.Run("RevokeCertificate_Success", func(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch {
case r.URL.Path == "/v1/sys/health":
switch r.URL.Path {
case "/v1/sys/health":
w.WriteHeader(http.StatusOK)
case r.URL.Path == "/v1/pki/revoke":
case "/v1/pki/revoke":
// Verify token
if r.Header.Get("X-Vault-Token") == "" {
w.WriteHeader(http.StatusForbidden)
@@ -356,10 +356,10 @@ func TestVaultConnector(t *testing.T) {
t.Run("RevokeCertificate_ServerError", func(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch {
case r.URL.Path == "/v1/sys/health":
switch r.URL.Path {
case "/v1/sys/health":
w.WriteHeader(http.StatusOK)
case r.URL.Path == "/v1/pki/revoke":
case "/v1/pki/revoke":
w.WriteHeader(http.StatusBadRequest)
w.Write([]byte(`{"errors":["serial not found"]}`))
default:
@@ -390,8 +390,8 @@ func TestVaultConnector(t *testing.T) {
expectedPEM := "-----BEGIN CERTIFICATE-----\nTESTCA\n-----END CERTIFICATE-----\n"
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch {
case r.URL.Path == "/v1/pki/ca/pem":
switch r.URL.Path {
case "/v1/pki/ca/pem":
w.WriteHeader(http.StatusOK)
w.Write([]byte(expectedPEM))
default: