Fix gosec, govet, and errorlint linter errors

Co-authored-by: Junie <junie@jetbrains.com>
This commit is contained in:
2026-03-15 10:04:12 -07:00
parent dd31e440e6
commit fbaf79a8a0
35 changed files with 236 additions and 232 deletions

View File

@@ -4,6 +4,7 @@ import (
"context"
"crypto/x509"
"encoding/pem"
"errors"
"strings"
"sync"
"testing"
@@ -15,8 +16,8 @@ import (
// memBarrier is an in-memory barrier for testing.
type memBarrier struct {
mu sync.RWMutex
data map[string][]byte
mu sync.RWMutex
}
func newMemBarrier() *memBarrier {
@@ -82,7 +83,7 @@ func setupEngine(t *testing.T) (*CAEngine, *memBarrier) {
ctx := context.Background()
config := map[string]interface{}{
"organization": "TestOrg",
"organization": "TestOrg",
"key_algorithm": "ecdsa",
"key_size": float64(256),
"root_expiry": "87600h",
@@ -133,7 +134,7 @@ func TestInitializeWithImportedRoot(t *testing.T) {
ctx := context.Background()
config := map[string]interface{}{
"organization": "ImportOrg",
"organization": "ImportOrg",
"root_cert_pem": string(rootPEM),
"root_key_pem": string(srcKeyPEM),
}
@@ -272,7 +273,7 @@ func TestCreateIssuerRejectsNonAdmin(t *testing.T) {
if err == nil {
t.Fatal("expected error for non-admin create-issuer")
}
if err != ErrForbidden {
if !errors.Is(err, ErrForbidden) {
t.Errorf("expected ErrForbidden, got: %v", err)
}
}
@@ -289,7 +290,7 @@ func TestCreateIssuerRejectsNilCallerInfo(t *testing.T) {
}
_, err := eng.HandleRequest(ctx, req)
if err != ErrUnauthorized {
if !errors.Is(err, ErrUnauthorized) {
t.Errorf("expected ErrUnauthorized, got: %v", err)
}
}
@@ -427,7 +428,7 @@ func TestIssueRejectsNilCallerInfo(t *testing.T) {
"common_name": "test.example.com",
},
})
if err != ErrUnauthorized {
if !errors.Is(err, ErrUnauthorized) {
t.Errorf("expected ErrUnauthorized, got: %v", err)
}
}
@@ -746,7 +747,7 @@ func TestImportRootRequiresAdmin(t *testing.T) {
"key_pem": "fake",
},
})
if err != ErrForbidden {
if !errors.Is(err, ErrForbidden) {
t.Errorf("expected ErrForbidden, got: %v", err)
}
}
@@ -798,7 +799,7 @@ func TestPublicMethods(t *testing.T) {
// Test nonexistent issuer.
_, err = eng.GetIssuerCertPEM("nonexistent")
if err != ErrIssuerNotFound {
if !errors.Is(err, ErrIssuerNotFound) {
t.Errorf("expected ErrIssuerNotFound, got: %v", err)
}
}