diff options
author | Valery Piashchynski <[email protected]> | 2021-01-21 13:25:36 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-01-21 13:25:36 +0300 |
commit | 7da6c78449776e1f3c6716250bca0b712a0423a4 (patch) | |
tree | f3512de66aca2bba408485a0ea2fc936c0e4fb9b /tests/plugins/http | |
parent | 0ff05b2732b4fd0783f959c94c54d7e39169f979 (diff) |
Uniform all configs
Add debug server
Check nil's for all plugin intialization
Diffstat (limited to 'tests/plugins/http')
-rw-r--r-- | tests/plugins/http/configs/.rr-ssl.yaml | 6 | ||||
-rw-r--r-- | tests/plugins/http/handler_test.go | 65 | ||||
-rw-r--r-- | tests/plugins/http/uploads_config_test.go | 8 | ||||
-rw-r--r-- | tests/plugins/http/uploads_test.go | 9 |
4 files changed, 42 insertions, 46 deletions
diff --git a/tests/plugins/http/configs/.rr-ssl.yaml b/tests/plugins/http/configs/.rr-ssl.yaml index 182ac7ef..c3e45365 100644 --- a/tests/plugins/http/configs/.rr-ssl.yaml +++ b/tests/plugins/http/configs/.rr-ssl.yaml @@ -8,7 +8,6 @@ server: relay_timeout: "20s" http: - debug: true address: :8085 max_request_size: 1024 middleware: [ "" ] @@ -26,13 +25,8 @@ http: redirect: false cert: fixtures/server.crt key: fixtures/server.key - # rootCa: root.crt fcgi: address: tcp://0.0.0.0:16920 - http2: - enabled: false - h2c: false - maxConcurrentStreams: 128 logs: mode: development level: error
\ No newline at end of file diff --git a/tests/plugins/http/handler_test.go b/tests/plugins/http/handler_test.go index 18558296..ee6f795d 100644 --- a/tests/plugins/http/handler_test.go +++ b/tests/plugins/http/handler_test.go @@ -13,6 +13,7 @@ import ( "github.com/spiral/roadrunner/v2/pkg/pipe" poolImpl "github.com/spiral/roadrunner/v2/pkg/pool" httpPlugin "github.com/spiral/roadrunner/v2/plugins/http" + "github.com/spiral/roadrunner/v2/plugins/http/config" "github.com/stretchr/testify/assert" "net/http" @@ -34,7 +35,7 @@ func TestHandler_Echo(t *testing.T) { t.Fatal(err) } - h, err := httpPlugin.NewHandler(1024, httpPlugin.UploadsConfig{ + h, err := httpPlugin.NewHandler(1024, config.Uploads{ Dir: os.TempDir(), Forbid: []string{}, }, nil, pool) @@ -65,7 +66,7 @@ func TestHandler_Echo(t *testing.T) { } func Test_HandlerErrors(t *testing.T) { - _, err := httpPlugin.NewHandler(1024, httpPlugin.UploadsConfig{ + _, err := httpPlugin.NewHandler(1024, config.Uploads{ Dir: os.TempDir(), Forbid: []string{}, }, nil, nil) @@ -88,7 +89,7 @@ func TestHandler_Headers(t *testing.T) { pool.Destroy(context.Background()) }() - h, err := httpPlugin.NewHandler(1024, httpPlugin.UploadsConfig{ + h, err := httpPlugin.NewHandler(1024, config.Uploads{ Dir: os.TempDir(), Forbid: []string{}, }, nil, pool) @@ -149,7 +150,7 @@ func TestHandler_Empty_User_Agent(t *testing.T) { pool.Destroy(context.Background()) }() - h, err := httpPlugin.NewHandler(1024, httpPlugin.UploadsConfig{ + h, err := httpPlugin.NewHandler(1024, config.Uploads{ Dir: os.TempDir(), Forbid: []string{}, }, nil, pool) @@ -209,7 +210,7 @@ func TestHandler_User_Agent(t *testing.T) { pool.Destroy(context.Background()) }() - h, err := httpPlugin.NewHandler(1024, httpPlugin.UploadsConfig{ + h, err := httpPlugin.NewHandler(1024, config.Uploads{ Dir: os.TempDir(), Forbid: []string{}, }, nil, pool) @@ -269,7 +270,7 @@ func TestHandler_Cookies(t *testing.T) { pool.Destroy(context.Background()) }() - h, err := httpPlugin.NewHandler(1024, httpPlugin.UploadsConfig{ + h, err := httpPlugin.NewHandler(1024, config.Uploads{ Dir: os.TempDir(), Forbid: []string{}, }, nil, pool) @@ -334,7 +335,7 @@ func TestHandler_JsonPayload_POST(t *testing.T) { pool.Destroy(context.Background()) }() - h, err := httpPlugin.NewHandler(1024, httpPlugin.UploadsConfig{ + h, err := httpPlugin.NewHandler(1024, config.Uploads{ Dir: os.TempDir(), Forbid: []string{}, }, nil, pool) @@ -398,7 +399,7 @@ func TestHandler_JsonPayload_PUT(t *testing.T) { pool.Destroy(context.Background()) }() - h, err := httpPlugin.NewHandler(1024, httpPlugin.UploadsConfig{ + h, err := httpPlugin.NewHandler(1024, config.Uploads{ Dir: os.TempDir(), Forbid: []string{}, }, nil, pool) @@ -458,7 +459,7 @@ func TestHandler_JsonPayload_PATCH(t *testing.T) { pool.Destroy(context.Background()) }() - h, err := httpPlugin.NewHandler(1024, httpPlugin.UploadsConfig{ + h, err := httpPlugin.NewHandler(1024, config.Uploads{ Dir: os.TempDir(), Forbid: []string{}, }, nil, pool) @@ -518,7 +519,7 @@ func TestHandler_FormData_POST(t *testing.T) { pool.Destroy(context.Background()) }() - h, err := httpPlugin.NewHandler(1024, httpPlugin.UploadsConfig{ + h, err := httpPlugin.NewHandler(1024, config.Uploads{ Dir: os.TempDir(), Forbid: []string{}, }, nil, pool) @@ -591,7 +592,7 @@ func TestHandler_FormData_POST_Overwrite(t *testing.T) { pool.Destroy(context.Background()) }() - h, err := httpPlugin.NewHandler(1024, httpPlugin.UploadsConfig{ + h, err := httpPlugin.NewHandler(1024, config.Uploads{ Dir: os.TempDir(), Forbid: []string{}, }, nil, pool) @@ -664,7 +665,7 @@ func TestHandler_FormData_POST_Form_UrlEncoded_Charset(t *testing.T) { pool.Destroy(context.Background()) }() - h, err := httpPlugin.NewHandler(1024, httpPlugin.UploadsConfig{ + h, err := httpPlugin.NewHandler(1024, config.Uploads{ Dir: os.TempDir(), Forbid: []string{}, }, nil, pool) @@ -736,7 +737,7 @@ func TestHandler_FormData_PUT(t *testing.T) { pool.Destroy(context.Background()) }() - h, err := httpPlugin.NewHandler(1024, httpPlugin.UploadsConfig{ + h, err := httpPlugin.NewHandler(1024, config.Uploads{ Dir: os.TempDir(), Forbid: []string{}, }, nil, pool) @@ -808,7 +809,7 @@ func TestHandler_FormData_PATCH(t *testing.T) { pool.Destroy(context.Background()) }() - h, err := httpPlugin.NewHandler(1024, httpPlugin.UploadsConfig{ + h, err := httpPlugin.NewHandler(1024, config.Uploads{ Dir: os.TempDir(), Forbid: []string{}, }, nil, pool) @@ -880,7 +881,7 @@ func TestHandler_Multipart_POST(t *testing.T) { pool.Destroy(context.Background()) }() - h, err := httpPlugin.NewHandler(1024, httpPlugin.UploadsConfig{ + h, err := httpPlugin.NewHandler(1024, config.Uploads{ Dir: os.TempDir(), Forbid: []string{}, }, nil, pool) @@ -994,7 +995,7 @@ func TestHandler_Multipart_PUT(t *testing.T) { pool.Destroy(context.Background()) }() - h, err := httpPlugin.NewHandler(1024, httpPlugin.UploadsConfig{ + h, err := httpPlugin.NewHandler(1024, config.Uploads{ Dir: os.TempDir(), Forbid: []string{}, }, nil, pool) @@ -1108,7 +1109,7 @@ func TestHandler_Multipart_PATCH(t *testing.T) { pool.Destroy(context.Background()) }() - h, err := httpPlugin.NewHandler(1024, httpPlugin.UploadsConfig{ + h, err := httpPlugin.NewHandler(1024, config.Uploads{ Dir: os.TempDir(), Forbid: []string{}, }, nil, pool) @@ -1224,7 +1225,7 @@ func TestHandler_Error(t *testing.T) { pool.Destroy(context.Background()) }() - h, err := httpPlugin.NewHandler(1024, httpPlugin.UploadsConfig{ + h, err := httpPlugin.NewHandler(1024, config.Uploads{ Dir: os.TempDir(), Forbid: []string{}, }, nil, pool) @@ -1270,7 +1271,7 @@ func TestHandler_Error2(t *testing.T) { pool.Destroy(context.Background()) }() - h, err := httpPlugin.NewHandler(1024, httpPlugin.UploadsConfig{ + h, err := httpPlugin.NewHandler(1024, config.Uploads{ Dir: os.TempDir(), Forbid: []string{}, }, nil, pool) @@ -1316,7 +1317,7 @@ func TestHandler_Error3(t *testing.T) { pool.Destroy(context.Background()) }() - h, err := httpPlugin.NewHandler(1, httpPlugin.UploadsConfig{ + h, err := httpPlugin.NewHandler(1, config.Uploads{ Dir: os.TempDir(), Forbid: []string{}, }, nil, pool) @@ -1375,7 +1376,7 @@ func TestHandler_ResponseDuration(t *testing.T) { pool.Destroy(context.Background()) }() - h, err := httpPlugin.NewHandler(1024, httpPlugin.UploadsConfig{ + h, err := httpPlugin.NewHandler(1024, config.Uploads{ Dir: os.TempDir(), Forbid: []string{}, }, nil, pool) @@ -1436,7 +1437,7 @@ func TestHandler_ResponseDurationDelayed(t *testing.T) { pool.Destroy(context.Background()) }() - h, err := httpPlugin.NewHandler(1024, httpPlugin.UploadsConfig{ + h, err := httpPlugin.NewHandler(1024, config.Uploads{ Dir: os.TempDir(), Forbid: []string{}, }, nil, pool) @@ -1496,7 +1497,7 @@ func TestHandler_ErrorDuration(t *testing.T) { pool.Destroy(context.Background()) }() - h, err := httpPlugin.NewHandler(1024, httpPlugin.UploadsConfig{ + h, err := httpPlugin.NewHandler(1024, config.Uploads{ Dir: os.TempDir(), Forbid: []string{}, }, nil, pool) @@ -1551,7 +1552,7 @@ func TestHandler_IP(t *testing.T) { "fe80::/10", } - cidrs, err := httpPlugin.ParseCIDRs(trusted) + cidrs, err := config.ParseCIDRs(trusted) assert.NoError(t, err) assert.NotNil(t, cidrs) @@ -1570,7 +1571,7 @@ func TestHandler_IP(t *testing.T) { pool.Destroy(context.Background()) }() - h, err := httpPlugin.NewHandler(1024, httpPlugin.UploadsConfig{ + h, err := httpPlugin.NewHandler(1024, config.Uploads{ Dir: os.TempDir(), Forbid: []string{}, }, cidrs, pool) @@ -1612,7 +1613,7 @@ func TestHandler_XRealIP(t *testing.T) { "fe80::/10", } - cidrs, err := httpPlugin.ParseCIDRs(trusted) + cidrs, err := config.ParseCIDRs(trusted) assert.NoError(t, err) assert.NotNil(t, cidrs) @@ -1631,7 +1632,7 @@ func TestHandler_XRealIP(t *testing.T) { pool.Destroy(context.Background()) }() - h, err := httpPlugin.NewHandler(1024, httpPlugin.UploadsConfig{ + h, err := httpPlugin.NewHandler(1024, config.Uploads{ Dir: os.TempDir(), Forbid: []string{}, }, cidrs, pool) @@ -1678,7 +1679,7 @@ func TestHandler_XForwardedFor(t *testing.T) { "fe80::/10", } - cidrs, err := httpPlugin.ParseCIDRs(trusted) + cidrs, err := config.ParseCIDRs(trusted) assert.NoError(t, err) assert.NotNil(t, cidrs) @@ -1697,7 +1698,7 @@ func TestHandler_XForwardedFor(t *testing.T) { pool.Destroy(context.Background()) }() - h, err := httpPlugin.NewHandler(1024, httpPlugin.UploadsConfig{ + h, err := httpPlugin.NewHandler(1024, config.Uploads{ Dir: os.TempDir(), Forbid: []string{}, }, cidrs, pool) @@ -1743,7 +1744,7 @@ func TestHandler_XForwardedFor_NotTrustedRemoteIp(t *testing.T) { "10.0.0.0/8", } - cidrs, err := httpPlugin.ParseCIDRs(trusted) + cidrs, err := config.ParseCIDRs(trusted) assert.NoError(t, err) assert.NotNil(t, cidrs) @@ -1762,7 +1763,7 @@ func TestHandler_XForwardedFor_NotTrustedRemoteIp(t *testing.T) { pool.Destroy(context.Background()) }() - h, err := httpPlugin.NewHandler(1024, httpPlugin.UploadsConfig{ + h, err := httpPlugin.NewHandler(1024, config.Uploads{ Dir: os.TempDir(), Forbid: []string{}, }, cidrs, pool) @@ -1810,7 +1811,7 @@ func BenchmarkHandler_Listen_Echo(b *testing.B) { pool.Destroy(context.Background()) }() - h, err := httpPlugin.NewHandler(1024, httpPlugin.UploadsConfig{ + h, err := httpPlugin.NewHandler(1024, config.Uploads{ Dir: os.TempDir(), Forbid: []string{}, }, nil, pool) diff --git a/tests/plugins/http/uploads_config_test.go b/tests/plugins/http/uploads_config_test.go index e76078ee..4f99b621 100644 --- a/tests/plugins/http/uploads_config_test.go +++ b/tests/plugins/http/uploads_config_test.go @@ -4,12 +4,12 @@ import ( "os" "testing" - httpPlugin "github.com/spiral/roadrunner/v2/plugins/http" + "github.com/spiral/roadrunner/v2/plugins/http/config" "github.com/stretchr/testify/assert" ) func TestFsConfig_Forbids(t *testing.T) { - cfg := httpPlugin.UploadsConfig{Forbid: []string{".php"}} + cfg := config.Uploads{Forbid: []string{".php"}} assert.True(t, cfg.Forbids("index.php")) assert.True(t, cfg.Forbids("index.PHP")) @@ -18,9 +18,9 @@ func TestFsConfig_Forbids(t *testing.T) { } func TestFsConfig_TmpFallback(t *testing.T) { - cfg := httpPlugin.UploadsConfig{Dir: "test"} + cfg := config.Uploads{Dir: "test"} assert.Equal(t, "test", cfg.TmpDir()) - cfg = httpPlugin.UploadsConfig{Dir: ""} + cfg = config.Uploads{Dir: ""} assert.Equal(t, os.TempDir(), cfg.TmpDir()) } diff --git a/tests/plugins/http/uploads_test.go b/tests/plugins/http/uploads_test.go index 7bb25cbf..e03638d2 100644 --- a/tests/plugins/http/uploads_test.go +++ b/tests/plugins/http/uploads_test.go @@ -19,6 +19,7 @@ import ( "github.com/spiral/roadrunner/v2/pkg/pipe" poolImpl "github.com/spiral/roadrunner/v2/pkg/pool" httpPlugin "github.com/spiral/roadrunner/v2/plugins/http" + "github.com/spiral/roadrunner/v2/plugins/http/config" "github.com/stretchr/testify/assert" ) @@ -39,7 +40,7 @@ func TestHandler_Upload_File(t *testing.T) { t.Fatal(err) } - h, err := httpPlugin.NewHandler(1024, httpPlugin.UploadsConfig{ + h, err := httpPlugin.NewHandler(1024, config.Uploads{ Dir: os.TempDir(), Forbid: []string{}, }, nil, pool) @@ -122,7 +123,7 @@ func TestHandler_Upload_NestedFile(t *testing.T) { t.Fatal(err) } - h, err := httpPlugin.NewHandler(1024, httpPlugin.UploadsConfig{ + h, err := httpPlugin.NewHandler(1024, config.Uploads{ Dir: os.TempDir(), Forbid: []string{}, }, nil, pool) @@ -205,7 +206,7 @@ func TestHandler_Upload_File_NoTmpDir(t *testing.T) { t.Fatal(err) } - h, err := httpPlugin.NewHandler(1024, httpPlugin.UploadsConfig{ + h, err := httpPlugin.NewHandler(1024, config.Uploads{ Dir: "-------", Forbid: []string{}, }, nil, pool) @@ -288,7 +289,7 @@ func TestHandler_Upload_File_Forbids(t *testing.T) { t.Fatal(err) } - h, err := httpPlugin.NewHandler(1024, httpPlugin.UploadsConfig{ + h, err := httpPlugin.NewHandler(1024, config.Uploads{ Dir: os.TempDir(), Forbid: []string{".go"}, }, nil, pool) |