From f6359114607f9daa41aa90d452ebdc970615c3ab Mon Sep 17 00:00:00 2001 From: Valery Piashchynski Date: Sun, 25 Apr 2021 20:18:35 +0300 Subject: - Initial commit of the updated static plugin Signed-off-by: Valery Piashchynski --- tests/plugins/static/config_test.go | 49 ---------------------- .../static/configs/.rr-http-static-files.yaml | 8 +--- tests/plugins/static/static_plugin_test.go | 3 +- 3 files changed, 4 insertions(+), 56 deletions(-) delete mode 100644 tests/plugins/static/config_test.go (limited to 'tests/plugins') diff --git a/tests/plugins/static/config_test.go b/tests/plugins/static/config_test.go deleted file mode 100644 index d73fd845..00000000 --- a/tests/plugins/static/config_test.go +++ /dev/null @@ -1,49 +0,0 @@ -package static - -import ( - "testing" - - "github.com/spiral/roadrunner/v2/plugins/static" - "github.com/stretchr/testify/assert" -) - -func TestConfig_Forbids(t *testing.T) { - cfg := static.Config{Static: &struct { - Dir string - Forbid []string - Always []string - Request map[string]string - Response map[string]string - }{Dir: "", Forbid: []string{".php"}, Always: nil, Request: nil, Response: nil}} - - assert.True(t, cfg.AlwaysForbid("index.php")) - assert.True(t, cfg.AlwaysForbid("index.PHP")) - assert.True(t, cfg.AlwaysForbid("phpadmin/index.bak.php")) - assert.False(t, cfg.AlwaysForbid("index.html")) -} - -func TestConfig_Valid(t *testing.T) { - assert.NoError(t, (&static.Config{Static: &struct { - Dir string - Forbid []string - Always []string - Request map[string]string - Response map[string]string - }{Dir: "./"}}).Valid()) - - assert.Error(t, (&static.Config{Static: &struct { - Dir string - Forbid []string - Always []string - Request map[string]string - Response map[string]string - }{Dir: "./http.go"}}).Valid()) - - assert.Error(t, (&static.Config{Static: &struct { - Dir string - Forbid []string - Always []string - Request map[string]string - Response map[string]string - }{Dir: "./dir/"}}).Valid()) -} diff --git a/tests/plugins/static/configs/.rr-http-static-files.yaml b/tests/plugins/static/configs/.rr-http-static-files.yaml index d6b3032e..0e003dae 100644 --- a/tests/plugins/static/configs/.rr-http-static-files.yaml +++ b/tests/plugins/static/configs/.rr-http-static-files.yaml @@ -18,11 +18,7 @@ http: dir: "../../../tests" forbid: [ ".php", ".htaccess" ] always: [ ".ico" ] - request: - "Example-Request-Header": "Value" - # Automatically add headers to every response. - response: - "X-Powered-By": "RoadRunner" + pool: num_workers: 2 max_jobs: 0 @@ -30,4 +26,4 @@ http: destroy_timeout: 60s logs: mode: development - level: error \ No newline at end of file + level: error diff --git a/tests/plugins/static/static_plugin_test.go b/tests/plugins/static/static_plugin_test.go index 38562537..b58f1f6b 100644 --- a/tests/plugins/static/static_plugin_test.go +++ b/tests/plugins/static/static_plugin_test.go @@ -259,7 +259,8 @@ func TestStaticFilesForbid(t *testing.T) { err = cont.RegisterAll( cfg, - mockLogger, + //mockLogger, + &logger.ZapLogger{}, &server.Plugin{}, &httpPlugin.Plugin{}, &gzip.Plugin{}, -- cgit v1.2.3