| 9 | "github.com/fatedier/frp/test/e2e/framework/consts" |
| 10 | "github.com/fatedier/frp/test/e2e/pkg/port" |
| 11 | ) |
| 12 |
| 13 | var _ = ginkgo.Describe("[Feature: Config]", func() { |
| 14 | f := framework.NewDefaultFramework() |
| 15 |
| 16 | ginkgo.Describe("Template", func() { |
| 17 | ginkgo.It("render by env", func() { |
| 18 | serverConf := consts.LegacyDefaultServerConfig |
| 19 | clientConf := consts.LegacyDefaultClientConfig |
| 20 |
| 21 | portName := port.GenName("TCP") |
| 22 | serverConf += fmt.Sprintf(` |
| 23 | token = {{ %s{{ .Envs.FRP_TOKEN }}%s }} |
| 24 | `, "`", "`") |
| 25 |
| 26 | clientConf += fmt.Sprintf(` |
| 27 | token = {{ %s{{ .Envs.FRP_TOKEN }}%s }} |
| 28 |
| 29 | [tcp] |
| 30 | type = tcp |
| 31 | local_port = {{ .%s }} |
| 32 | remote_port = {{ .%s }} |
| 33 | `, "`", "`", framework.TCPEchoServerPort, portName) |
| 34 |
| 35 | f.SetEnvs([]string{"FRP_TOKEN=123"}) |
| 36 | f.RunProcesses(serverConf, []string{clientConf}) |
| 37 |
| 38 | framework.NewRequestExpect(f).PortName(portName).Ensure() |
| 39 | }) |
| 40 | }) |
| 41 |
| 42 | ginkgo.Describe("Includes", func() { |
| 43 | ginkgo.It("split tcp proxies into different files", func() { |
| 44 | serverPort := f.AllocPort() |
| 45 | serverConfigPath := f.GenerateConfigFile(fmt.Sprintf(` |
| 46 | [common] |
| 47 | bind_addr = 0.0.0.0 |
| 48 | bind_port = %d |
| 49 | `, serverPort)) |
| 50 |
| 51 | remotePort := f.AllocPort() |
| 52 | proxyConfigPath := f.GenerateConfigFile(fmt.Sprintf(` |
| 53 | [tcp] |
| 54 | type = tcp |
| 55 | local_port = %d |
| 56 | remote_port = %d |
| 57 | `, f.PortByName(framework.TCPEchoServerPort), remotePort)) |
| 58 |
| 59 | remotePort2 := f.AllocPort() |
| 60 | proxyConfigPath2 := f.GenerateConfigFile(fmt.Sprintf(` |
| 61 | [tcp2] |
| 62 | type = tcp |
| 63 | local_port = %d |
| 64 | remote_port = %d |
| 65 | `, f.PortByName(framework.TCPEchoServerPort), remotePort2)) |
| 66 |
| 67 | clientConfigPath := f.GenerateConfigFile(fmt.Sprintf(` |
| 68 | [common] |
| 69 | server_port = %d |
| 70 | includes = %s,%s |
| 71 | `, serverPort, proxyConfigPath, proxyConfigPath2)) |
| 72 |
| 73 | _, _, err := f.RunFrps("-c", serverConfigPath) |
| 74 | framework.ExpectNoError(err) |
| 75 |
| 76 | _, _, err = f.RunFrpc("-c", clientConfigPath) |
| 77 | framework.ExpectNoError(err) |
| 78 |
| 79 | framework.NewRequestExpect(f).Port(remotePort).Ensure() |
| 80 | framework.NewRequestExpect(f).Port(remotePort2).Ensure() |
| 81 | }) |
| 82 | }) |
| 83 | }) |