http_test.go 862 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package v4_test
  2. import (
  3. "testing"
  4. "github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
  5. "github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/testassist"
  6. "github.com/v2fly/v2ray-core/v4/infra/conf/v4"
  7. "github.com/v2fly/v2ray-core/v4/proxy/http"
  8. )
  9. func TestHTTPServerConfig(t *testing.T) {
  10. creator := func() cfgcommon.Buildable {
  11. return new(v4.HTTPServerConfig)
  12. }
  13. testassist.RunMultiTestCase(t, []testassist.TestCase{
  14. {
  15. Input: `{
  16. "timeout": 10,
  17. "accounts": [
  18. {
  19. "user": "my-username",
  20. "pass": "my-password"
  21. }
  22. ],
  23. "allowTransparent": true,
  24. "userLevel": 1
  25. }`,
  26. Parser: testassist.LoadJSON(creator),
  27. Output: &http.ServerConfig{
  28. Accounts: map[string]string{
  29. "my-username": "my-password",
  30. },
  31. AllowTransparent: true,
  32. UserLevel: 1,
  33. Timeout: 10,
  34. },
  35. },
  36. })
  37. }