From aac2233b1a1c0f02e94f75eee73d8c5f37128238 Mon Sep 17 00:00:00 2001 From: Tim Ramlot <42113979+inteon@users.noreply.github.com> Date: Mon, 29 Apr 2024 15:18:01 +0200 Subject: [PATCH] fix ginkgolinter linter Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com> --- .golangci.yaml | 1 - test/e2e/framework/matcher/san_matchers.go | 2 +- test/e2e/suite/certificates/additionaloutputformats.go | 2 +- test/e2e/suite/certificates/literalsubjectrdns.go | 6 +++--- test/e2e/suite/certificates/othernamesan.go | 8 ++++---- test/e2e/suite/conformance/certificates/tests.go | 2 +- 6 files changed, 10 insertions(+), 11 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index 289c72dbd..c002c7d69 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -25,7 +25,6 @@ issues: - gosimple - nakedret - asasalint - - ginkgolinter - goprintffuncname - ineffassign - musttag diff --git a/test/e2e/framework/matcher/san_matchers.go b/test/e2e/framework/matcher/san_matchers.go index 4100f6ce0..76c8b2c77 100644 --- a/test/e2e/framework/matcher/san_matchers.go +++ b/test/e2e/framework/matcher/san_matchers.go @@ -126,7 +126,7 @@ var oidExtensionSubjectAltName = []int{2, 5, 29, 17} func extractSANsFromCertificate(certDER string) pkix.Extension { block, rest := pem.Decode([]byte(certDER)) - Expect(len(rest)).To(Equal(0)) + Expect(rest).To(BeEmpty()) cert, err := x509.ParseCertificate(block.Bytes) Expect(err).NotTo(HaveOccurred()) diff --git a/test/e2e/suite/certificates/additionaloutputformats.go b/test/e2e/suite/certificates/additionaloutputformats.go index 07f66901d..c4f1d5ab8 100644 --- a/test/e2e/suite/certificates/additionaloutputformats.go +++ b/test/e2e/suite/certificates/additionaloutputformats.go @@ -367,7 +367,7 @@ var _ = framework.CertManagerDescribe("Certificate AdditionalCertificateOutputFo continue } var fieldset fieldpath.Set - Expect(fieldset.FromJSON(bytes.NewReader(managedField.FieldsV1.Raw))) + Expect(fieldset.FromJSON(bytes.NewReader(managedField.FieldsV1.Raw))).NotTo(HaveOccurred()) if fieldset.Has(fieldpath.Path{ {FieldName: ptr.To("data")}, {FieldName: ptr.To("tls-combined.pem")}, diff --git a/test/e2e/suite/certificates/literalsubjectrdns.go b/test/e2e/suite/certificates/literalsubjectrdns.go index 07c30b9d5..eb6b3f9cf 100644 --- a/test/e2e/suite/certificates/literalsubjectrdns.go +++ b/test/e2e/suite/certificates/literalsubjectrdns.go @@ -97,12 +97,12 @@ var _ = framework.CertManagerDescribe("literalsubject rdn parsing", func() { Expect(err).NotTo(HaveOccurred(), "failed to wait for Certificate to become Ready") secret, err := f.KubeClientSet.CoreV1().Secrets(f.Namespace.Name).Get(context.TODO(), secretName, metav1.GetOptions{}) - Expect(err).To(BeNil()) + Expect(err).NotTo(HaveOccurred()) Expect(secret.Data).To(HaveKey("tls.crt")) crtPEM := secret.Data["tls.crt"] pemBlock, _ := pem.Decode(crtPEM) cert, err := x509.ParseCertificate(pemBlock.Bytes) - Expect(err).To(BeNil()) + Expect(err).NotTo(HaveOccurred()) Expect(cert.Subject.Names).To(Equal([]pkix.AttributeTypeAndValue{ {Type: asn1.ObjectIdentifier{2, 5, 4, 6}, Value: "Spain"}, @@ -121,7 +121,7 @@ var _ = framework.CertManagerDescribe("literalsubject rdn parsing", func() { It("Should not allow unknown RDN component", func() { _, err := createCertificate(f, "UNKNOWN=blah") - Expect(err).NotTo(BeNil()) + Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("Literal subject contains unrecognized key with value [blah]")) }) diff --git a/test/e2e/suite/certificates/othernamesan.go b/test/e2e/suite/certificates/othernamesan.go index 1f6c3f123..44bf3692b 100644 --- a/test/e2e/suite/certificates/othernamesan.go +++ b/test/e2e/suite/certificates/othernamesan.go @@ -103,12 +103,12 @@ var _ = framework.CertManagerDescribe("othername san processing", func() { Expect(err).NotTo(HaveOccurred(), "failed to wait for Certificate to become Ready") secret, err := f.KubeClientSet.CoreV1().Secrets(f.Namespace.Name).Get(context.TODO(), secretName, metav1.GetOptions{}) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) Expect(secret.Data).To(HaveKey("tls.crt")) crtPEM := secret.Data["tls.crt"] pemBlock, _ := pem.Decode(crtPEM) cert, err := x509.ParseCertificate(pemBlock.Bytes) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) By("Including the appropriate GeneralNames ( RFC822 email Address and OtherName) in generated Certificate") @@ -151,7 +151,7 @@ YH0ROM05IRf2nOI6KInaiz4POk6JvdTb UTF8Value: "user@example.org", }, }) - Expect(err).NotTo(BeNil()) + Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("admission webhook \"webhook.cert-manager.io\" denied the request: spec.otherNames[0].oid: Invalid value: \"BAD_OID\": oid syntax invalid")) }) @@ -166,7 +166,7 @@ YH0ROM05IRf2nOI6KInaiz4POk6JvdTb UTF8Value: "user@example.org", }, }) - Expect(err).NotTo(BeNil()) + Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("admission webhook \"webhook.cert-manager.io\" denied the request: spec.otherNames[0].utf8Value: Required value: must be set to a valid non-empty UTF8 string")) }) diff --git a/test/e2e/suite/conformance/certificates/tests.go b/test/e2e/suite/conformance/certificates/tests.go index c44e12e10..d766da60c 100644 --- a/test/e2e/suite/conformance/certificates/tests.go +++ b/test/e2e/suite/conformance/certificates/tests.go @@ -267,7 +267,7 @@ func (s *Suite) Define() { pemBlock, _ := pem.Decode(certBytes) cert, err := x509.ParseCertificate(pemBlock.Bytes) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) By("Including the appropriate GeneralNames ( RFC822 email Address and OtherName) in generated Certificate") /* openssl req -nodes -newkey rsa:2048 -subj "/CN=someCN" \