frp/test/e2e/legacy/basic/config.go

84 lines
2.1 KiB
Go
Raw Normal View History

2021-06-18 08:48:36 +00:00
package basic
import (
"fmt"
2023-02-27 06:44:16 +00:00
"github.com/onsi/ginkgo/v2"
2022-08-28 17:02:53 +00:00
2021-06-18 08:48:36 +00:00
"github.com/fatedier/frp/test/e2e/framework"
"github.com/fatedier/frp/test/e2e/framework/consts"
"github.com/fatedier/frp/test/e2e/pkg/port"
)
2022-08-28 17:02:53 +00:00
var _ = ginkgo.Describe("[Feature: Config]", func() {
2021-06-18 08:48:36 +00:00
f := framework.NewDefaultFramework()
2022-08-28 17:02:53 +00:00
ginkgo.Describe("Template", func() {
ginkgo.It("render by env", func() {
2023-09-13 08:32:39 +00:00
serverConf := consts.LegacyDefaultServerConfig
clientConf := consts.LegacyDefaultClientConfig
2021-06-18 08:48:36 +00:00
portName := port.GenName("TCP")
serverConf += fmt.Sprintf(`
token = {{ %s{{ .Envs.FRP_TOKEN }}%s }}
`, "`", "`")
clientConf += fmt.Sprintf(`
token = {{ %s{{ .Envs.FRP_TOKEN }}%s }}
[tcp]
type = tcp
local_port = {{ .%s }}
remote_port = {{ .%s }}
`, "`", "`", framework.TCPEchoServerPort, portName)
f.SetEnvs([]string{"FRP_TOKEN=123"})
f.RunProcesses([]string{serverConf}, []string{clientConf})
framework.NewRequestExpect(f).PortName(portName).Ensure()
})
})
2022-08-28 17:02:53 +00:00
ginkgo.Describe("Includes", func() {
ginkgo.It("split tcp proxies into different files", func() {
2021-06-18 08:48:36 +00:00
serverPort := f.AllocPort()
serverConfigPath := f.GenerateConfigFile(fmt.Sprintf(`
[common]
bind_addr = 0.0.0.0
bind_port = %d
`, serverPort))
remotePort := f.AllocPort()
proxyConfigPath := f.GenerateConfigFile(fmt.Sprintf(`
[tcp]
type = tcp
local_port = %d
remote_port = %d
`, f.PortByName(framework.TCPEchoServerPort), remotePort))
remotePort2 := f.AllocPort()
proxyConfigPath2 := f.GenerateConfigFile(fmt.Sprintf(`
[tcp2]
type = tcp
local_port = %d
remote_port = %d
`, f.PortByName(framework.TCPEchoServerPort), remotePort2))
clientConfigPath := f.GenerateConfigFile(fmt.Sprintf(`
[common]
server_port = %d
includes = %s,%s
`, serverPort, proxyConfigPath, proxyConfigPath2))
_, _, err := f.RunFrps("-c", serverConfigPath)
framework.ExpectNoError(err)
_, _, err = f.RunFrpc("-c", clientConfigPath)
framework.ExpectNoError(err)
framework.NewRequestExpect(f).Port(remotePort).Ensure()
framework.NewRequestExpect(f).Port(remotePort2).Ensure()
})
})
})