Fix all errcheck linter issues
Co-authored-by: Junie <junie@jetbrains.com>
This commit is contained in:
@@ -79,7 +79,7 @@ func userCaller() *engine.CallerInfo {
|
||||
func setupEngine(t *testing.T) (*CAEngine, *memBarrier) {
|
||||
t.Helper()
|
||||
b := newMemBarrier()
|
||||
eng := NewCAEngine().(*CAEngine)
|
||||
eng := NewCAEngine().(*CAEngine) //nolint:errcheck
|
||||
ctx := context.Background()
|
||||
|
||||
config := map[string]interface{}{
|
||||
@@ -130,7 +130,7 @@ func TestInitializeWithImportedRoot(t *testing.T) {
|
||||
|
||||
// Now initialize a new engine with the imported root.
|
||||
b := newMemBarrier()
|
||||
eng := NewCAEngine().(*CAEngine)
|
||||
eng := NewCAEngine().(*CAEngine) //nolint:errcheck
|
||||
ctx := context.Background()
|
||||
|
||||
config := map[string]interface{}{
|
||||
@@ -230,7 +230,7 @@ func TestCreateIssuer(t *testing.T) {
|
||||
}
|
||||
|
||||
// Verify the issuer cert is an intermediate CA signed by root.
|
||||
certPEM := resp.Data["cert_pem"].(string)
|
||||
certPEM := resp.Data["cert_pem"].(string) //nolint:errcheck
|
||||
block, _ := pem.Decode([]byte(certPEM))
|
||||
if block == nil {
|
||||
t.Fatal("failed to decode issuer cert PEM")
|
||||
@@ -342,7 +342,7 @@ func TestIssueCertificate(t *testing.T) {
|
||||
}
|
||||
|
||||
// Verify the leaf cert.
|
||||
certPEM := resp.Data["cert_pem"].(string)
|
||||
certPEM := resp.Data["cert_pem"].(string) //nolint:errcheck
|
||||
block, _ := pem.Decode([]byte(certPEM))
|
||||
leafCert, err := x509.ParseCertificate(block.Bytes)
|
||||
if err != nil {
|
||||
@@ -389,7 +389,7 @@ func TestIssueCertificateWithOverrides(t *testing.T) {
|
||||
t.Fatalf("issue with overrides: %v", err)
|
||||
}
|
||||
|
||||
certPEM := resp.Data["cert_pem"].(string)
|
||||
certPEM := resp.Data["cert_pem"].(string) //nolint:errcheck
|
||||
block, _ := pem.Decode([]byte(certPEM))
|
||||
leafCert, err := x509.ParseCertificate(block.Bytes)
|
||||
if err != nil {
|
||||
@@ -459,7 +459,7 @@ func TestPrivateKeyNotStoredInBarrier(t *testing.T) {
|
||||
t.Fatalf("issue: %v", err)
|
||||
}
|
||||
|
||||
serial := resp.Data["serial"].(string)
|
||||
serial := resp.Data["serial"].(string) //nolint:errcheck
|
||||
|
||||
// Check that the cert record does not contain a private key.
|
||||
recordData, err := b.Get(ctx, "engine/ca/test/certs/"+serial+".json")
|
||||
@@ -499,7 +499,7 @@ func TestRenewCertificate(t *testing.T) {
|
||||
t.Fatalf("issue: %v", err)
|
||||
}
|
||||
|
||||
origSerial := issueResp.Data["serial"].(string)
|
||||
origSerial := issueResp.Data["serial"].(string) //nolint:errcheck
|
||||
|
||||
// Renew.
|
||||
renewResp, err := eng.HandleRequest(ctx, &engine.Request{
|
||||
@@ -513,7 +513,7 @@ func TestRenewCertificate(t *testing.T) {
|
||||
t.Fatalf("renew: %v", err)
|
||||
}
|
||||
|
||||
newSerial := renewResp.Data["serial"].(string)
|
||||
newSerial := renewResp.Data["serial"].(string) //nolint:errcheck
|
||||
if newSerial == origSerial {
|
||||
t.Error("renewed cert should have different serial")
|
||||
}
|
||||
@@ -575,7 +575,7 @@ func TestGetAndListCerts(t *testing.T) {
|
||||
}
|
||||
|
||||
// Get a specific cert.
|
||||
serial := certs[0]["serial"].(string)
|
||||
serial := certs[0]["serial"].(string) //nolint:errcheck
|
||||
getResp, err := eng.HandleRequest(ctx, &engine.Request{
|
||||
Operation: "get-cert",
|
||||
CallerInfo: userCaller(),
|
||||
@@ -607,7 +607,7 @@ func TestUnsealRestoresIssuers(t *testing.T) {
|
||||
}
|
||||
|
||||
// Seal.
|
||||
eng.Seal()
|
||||
_ = eng.Seal()
|
||||
|
||||
// Unseal.
|
||||
if err := eng.Unseal(ctx, b, mountPath); err != nil {
|
||||
|
||||
@@ -98,7 +98,7 @@ func TestRegistryHandleRequest(t *testing.T) {
|
||||
})
|
||||
|
||||
ctx := context.Background()
|
||||
reg.Mount(ctx, "test", EngineTypeTransit, nil)
|
||||
_ = reg.Mount(ctx, "test", EngineTypeTransit, nil)
|
||||
|
||||
resp, err := reg.HandleRequest(ctx, "test", &Request{Operation: "encrypt"})
|
||||
if err != nil {
|
||||
@@ -121,8 +121,8 @@ func TestRegistrySealAll(t *testing.T) {
|
||||
})
|
||||
|
||||
ctx := context.Background()
|
||||
reg.Mount(ctx, "eng1", EngineTypeTransit, nil)
|
||||
reg.Mount(ctx, "eng2", EngineTypeTransit, nil)
|
||||
_ = reg.Mount(ctx, "eng1", EngineTypeTransit, nil)
|
||||
_ = reg.Mount(ctx, "eng2", EngineTypeTransit, nil)
|
||||
|
||||
if err := reg.SealAll(); err != nil {
|
||||
t.Fatalf("SealAll: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user