client_plugins.go 1.9 KB

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