lint by golangci-lint (#3080)

This commit is contained in:
fatedier
2022-08-29 01:02:53 +08:00
committed by GitHub
parent f4e4fbea62
commit 9d077b02cf
122 changed files with 947 additions and 1331 deletions

View File

@@ -4,12 +4,12 @@ import (
"fmt"
"strings"
"github.com/onsi/ginkgo"
"github.com/fatedier/frp/test/e2e/framework"
"github.com/fatedier/frp/test/e2e/framework/consts"
"github.com/fatedier/frp/test/e2e/pkg/cert"
"github.com/fatedier/frp/test/e2e/pkg/port"
. "github.com/onsi/ginkgo"
)
type generalTestConfigures struct {
@@ -54,15 +54,15 @@ func runClientServerTest(f *framework.Framework, configures *generalTestConfigur
// defineClientServerTest test a normal tcp and udp proxy with specified TestConfigures.
func defineClientServerTest(desc string, f *framework.Framework, configures *generalTestConfigures) {
It(desc, func() {
ginkgo.It(desc, func() {
runClientServerTest(f, configures)
})
}
var _ = Describe("[Feature: Client-Server]", func() {
var _ = ginkgo.Describe("[Feature: Client-Server]", func() {
f := framework.NewDefaultFramework()
Describe("Protocol", func() {
ginkgo.Describe("Protocol", func() {
supportProtocols := []string{"tcp", "kcp", "websocket"}
for _, protocol := range supportProtocols {
configures := &generalTestConfigures{
@@ -76,7 +76,7 @@ var _ = Describe("[Feature: Client-Server]", func() {
}
})
Describe("Authentication", func() {
ginkgo.Describe("Authentication", func() {
defineClientServerTest("Token Correct", f, &generalTestConfigures{
server: "token = 123456",
client: "token = 123456",
@@ -89,7 +89,7 @@ var _ = Describe("[Feature: Client-Server]", func() {
})
})
Describe("TLS", func() {
ginkgo.Describe("TLS", func() {
supportProtocols := []string{"tcp", "kcp", "websocket"}
for _, protocol := range supportProtocols {
tmp := protocol
@@ -114,7 +114,7 @@ var _ = Describe("[Feature: Client-Server]", func() {
})
})
Describe("TLS with custom certificate", func() {
ginkgo.Describe("TLS with custom certificate", func() {
supportProtocols := []string{"tcp", "kcp", "websocket"}
var (
@@ -122,7 +122,7 @@ var _ = Describe("[Feature: Client-Server]", func() {
serverCrtPath, serverKeyPath string
clientCrtPath, clientKeyPath string
)
JustBeforeEach(func() {
ginkgo.JustBeforeEach(func() {
generator := &cert.SelfSignedCertGenerator{}
artifacts, err := generator.Generate("0.0.0.0")
framework.ExpectNoError(err)
@@ -131,7 +131,8 @@ var _ = Describe("[Feature: Client-Server]", func() {
serverCrtPath = f.WriteTempFile("server.crt", string(artifacts.Cert))
serverKeyPath = f.WriteTempFile("server.key", string(artifacts.Key))
generator.SetCA(artifacts.CACert, artifacts.CAKey)
generator.Generate("0.0.0.0")
_, err = generator.Generate("0.0.0.0")
framework.ExpectNoError(err)
clientCrtPath = f.WriteTempFile("client.crt", string(artifacts.Cert))
clientKeyPath = f.WriteTempFile("client.key", string(artifacts.Key))
})
@@ -139,7 +140,7 @@ var _ = Describe("[Feature: Client-Server]", func() {
for _, protocol := range supportProtocols {
tmp := protocol
It("one-way authentication: "+tmp, func() {
ginkgo.It("one-way authentication: "+tmp, func() {
runClientServerTest(f, &generalTestConfigures{
server: fmt.Sprintf(`
protocol = %s
@@ -155,7 +156,7 @@ var _ = Describe("[Feature: Client-Server]", func() {
})
})
It("mutual authentication: "+tmp, func() {
ginkgo.It("mutual authentication: "+tmp, func() {
runClientServerTest(f, &generalTestConfigures{
server: fmt.Sprintf(`
protocol = %s
@@ -176,13 +177,13 @@ var _ = Describe("[Feature: Client-Server]", func() {
}
})
Describe("TLS with custom certificate and specified server name", func() {
ginkgo.Describe("TLS with custom certificate and specified server name", func() {
var (
caCrtPath string
serverCrtPath, serverKeyPath string
clientCrtPath, clientKeyPath string
)
JustBeforeEach(func() {
ginkgo.JustBeforeEach(func() {
generator := &cert.SelfSignedCertGenerator{}
artifacts, err := generator.Generate("example.com")
framework.ExpectNoError(err)
@@ -191,12 +192,13 @@ var _ = Describe("[Feature: Client-Server]", func() {
serverCrtPath = f.WriteTempFile("server.crt", string(artifacts.Cert))
serverKeyPath = f.WriteTempFile("server.key", string(artifacts.Key))
generator.SetCA(artifacts.CACert, artifacts.CAKey)
generator.Generate("example.com")
_, err = generator.Generate("example.com")
framework.ExpectNoError(err)
clientCrtPath = f.WriteTempFile("client.crt", string(artifacts.Cert))
clientKeyPath = f.WriteTempFile("client.key", string(artifacts.Key))
})
It("mutual authentication", func() {
ginkgo.It("mutual authentication", func() {
runClientServerTest(f, &generalTestConfigures{
server: fmt.Sprintf(`
tls_cert_file = %s
@@ -213,7 +215,7 @@ var _ = Describe("[Feature: Client-Server]", func() {
})
})
It("mutual authentication with incorrect server name", func() {
ginkgo.It("mutual authentication with incorrect server name", func() {
runClientServerTest(f, &generalTestConfigures{
server: fmt.Sprintf(`
tls_cert_file = %s
@@ -232,7 +234,7 @@ var _ = Describe("[Feature: Client-Server]", func() {
})
})
Describe("TLS with disable_custom_tls_first_byte", func() {
ginkgo.Describe("TLS with disable_custom_tls_first_byte", func() {
supportProtocols := []string{"tcp", "kcp", "websocket"}
for _, protocol := range supportProtocols {
tmp := protocol
@@ -250,7 +252,7 @@ var _ = Describe("[Feature: Client-Server]", func() {
}
})
Describe("IPv6 bind address", func() {
ginkgo.Describe("IPv6 bind address", func() {
supportProtocols := []string{"tcp", "kcp", "websocket"}
for _, protocol := range supportProtocols {
tmp := protocol