diff options
author | Valery Piashchynski <[email protected]> | 2021-04-25 20:18:35 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-04-25 20:18:35 +0300 |
commit | f6359114607f9daa41aa90d452ebdc970615c3ab (patch) | |
tree | d1bc215440949d6615b2c645396e0146843745fa /tests | |
parent | 92d089e0ecedaa1ccdf9e2700b9cb2b61f307b1d (diff) |
- Initial commit of the updated static plugin
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/plugins/static/config_test.go | 49 | ||||
-rw-r--r-- | tests/plugins/static/configs/.rr-http-static-files.yaml | 8 | ||||
-rw-r--r-- | tests/plugins/static/static_plugin_test.go | 3 |
3 files changed, 4 insertions, 56 deletions
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{}, |