client_plugins.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package plugin
  2. import (
  3. "fmt"
  4. "time"
  5. "github.com/fatedier/frp/test/e2e/framework"
  6. "github.com/fatedier/frp/test/e2e/framework/consts"
  7. . "github.com/onsi/ginkgo"
  8. )
  9. var connTimeout = 2 * time.Second
  10. var _ = Describe("[Feature: Client-Plugins]", func() {
  11. f := framework.NewDefaultFramework()
  12. Describe("UnixDomainSocket", func() {
  13. It("Expose a unix domain socket echo server", func() {
  14. serverConf := consts.DefaultServerConfig
  15. clientConf := consts.DefaultClientConfig
  16. getProxyConf := func(proxyName string, portName string, extra string) string {
  17. return fmt.Sprintf(`
  18. [%s]
  19. type = tcp
  20. remote_port = {{ .%s }}
  21. plugin = unix_domain_socket
  22. plugin_unix_path = {{ .%s }}
  23. `+extra, proxyName, portName, framework.UDSEchoServerAddr)
  24. }
  25. tests := []struct {
  26. proxyName string
  27. portName string
  28. extraConfig string
  29. }{
  30. {
  31. proxyName: "normal",
  32. portName: framework.GenPortName("Normal"),
  33. },
  34. {
  35. proxyName: "with-encryption",
  36. portName: framework.GenPortName("WithEncryption"),
  37. extraConfig: "use_encryption = true",
  38. },
  39. {
  40. proxyName: "with-compression",
  41. portName: framework.GenPortName("WithCompression"),
  42. extraConfig: "use_compression = true",
  43. },
  44. {
  45. proxyName: "with-encryption-and-compression",
  46. portName: framework.GenPortName("WithEncryptionAndCompression"),
  47. extraConfig: `
  48. use_encryption = true
  49. use_compression = true
  50. `,
  51. },
  52. }
  53. // build all client config
  54. for _, test := range tests {
  55. clientConf += getProxyConf(test.proxyName, test.portName, test.extraConfig) + "\n"
  56. }
  57. // run frps and frpc
  58. f.RunProcesses([]string{serverConf}, []string{clientConf})
  59. for _, test := range tests {
  60. framework.ExpectTCPRequest(f.UsedPorts[test.portName],
  61. []byte(consts.TestString), []byte(consts.TestString),
  62. connTimeout, test.proxyName)
  63. }
  64. })
  65. })
  66. })