diff options
author | Valery Piashchynski <[email protected]> | 2020-11-30 12:54:41 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2020-11-30 12:54:41 +0300 |
commit | 9402ea1e88d6e63b8b0388ad662d20b727b940d0 (patch) | |
tree | 3a012e3d4a891f35466d53a7e8a3a8f209a249bc /plugins/static/config_test.go | |
parent | b27564251f4dbb8e366a4940d79a5645e2b28d3c (diff) |
Static plugin initial commit
Diffstat (limited to 'plugins/static/config_test.go')
-rw-r--r-- | plugins/static/config_test.go | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/plugins/static/config_test.go b/plugins/static/config_test.go new file mode 100644 index 00000000..de88ded3 --- /dev/null +++ b/plugins/static/config_test.go @@ -0,0 +1,48 @@ +package static + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestConfig_Forbids(t *testing.T) { + cfg := 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, (&Config{Static: struct { + Dir string + Forbid []string + Always []string + Request map[string]string + Response map[string]string + }{Dir: "./"}}).Valid()) + + assert.Error(t, (&Config{Static: struct { + Dir string + Forbid []string + Always []string + Request map[string]string + Response map[string]string + }{Dir: "./config.go"}}).Valid()) + + assert.Error(t, (&Config{Static: struct { + Dir string + Forbid []string + Always []string + Request map[string]string + Response map[string]string + }{Dir: "./dir/"}}).Valid()) +} |