Skip to content

Commit a785d3b

Browse files
committed
Fix lint errors in tests
1 parent 512866f commit a785d3b

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

conformance/tests/backendtlspolicy.go

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"testing"
2121

2222
"k8s.io/apimachinery/pkg/types"
23+
2324
"sigs.k8s.io/gateway-api/conformance/utils/http"
2425
"sigs.k8s.io/gateway-api/conformance/utils/kubernetes"
2526
"sigs.k8s.io/gateway-api/conformance/utils/suite"

conformance/utils/kubernetes/certificate.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func generateRSACert(hosts []string, keyOut, certOut io.Writer) error {
9999
for _, h := range hosts {
100100
if ip := net.ParseIP(h); ip != nil {
101101
template.IPAddresses = append(template.IPAddresses, ip)
102-
} else if err := validateHost(h); err == nil {
102+
} else if err = validateHost(h); err == nil {
103103
template.DNSNames = append(template.DNSNames, h)
104104
}
105105
}

conformance/utils/kubernetes/certificate_test.go

+15-13
Original file line numberDiff line numberDiff line change
@@ -74,26 +74,28 @@ func Test_generateCACert(t *testing.T) {
7474
block, _ := pem.Decode(serverCert.Bytes())
7575
if block == nil {
7676
require.FailNow(t, "failed to decode PEM block containing cert")
77-
}
78-
if block.Type == "CERTIFICATE" {
79-
cert, err := x509.ParseCertificate(block.Bytes)
80-
require.NoError(t, err, "failed to parse certificate")
81-
for _, h := range tc.hosts {
82-
if err = cert.VerifyHostname(h); err != nil {
83-
require.EqualValues(t, tc.expectedErr, err.Error(), "certificate verification failed")
84-
} else if len(tc.hosts) < 2 && err == nil && tc.expectedErr != "" {
85-
require.EqualValues(t, tc.expectedErr, nil, "expected an error but certification verification succeeded")
77+
} else {
78+
if block.Type == "CERTIFICATE" {
79+
cert, err := x509.ParseCertificate(block.Bytes)
80+
require.NoError(t, err, "failed to parse certificate")
81+
for _, h := range tc.hosts {
82+
if err = cert.VerifyHostname(h); err != nil {
83+
require.EqualValues(t, tc.expectedErr, err.Error(), "certificate verification failed")
84+
} else if len(tc.hosts) < 2 && err == nil && tc.expectedErr != "" {
85+
require.EqualValues(t, tc.expectedErr, err, "expected an error but certification verification succeeded")
86+
}
8687
}
8788
}
8889
}
8990
// Test that the server key is decodable and parseable.
9091
block, _ = pem.Decode(serverKey.Bytes())
9192
if block == nil {
9293
require.FailNow(t, "failed to decode PEM block containing public key")
93-
}
94-
if block.Type == "RSA PRIVATE KEY" {
95-
_, err := x509.ParsePKCS1PrivateKey(block.Bytes)
96-
require.NoError(t, err, "failed to parse key")
94+
} else {
95+
if block.Type == "RSA PRIVATE KEY" {
96+
_, err := x509.ParsePKCS1PrivateKey(block.Bytes)
97+
require.NoError(t, err, "failed to parse key")
98+
}
9799
}
98100
})
99101
}

0 commit comments

Comments
 (0)