blob: d73fd845c90b12685b0ed0aa3af76048fccc9132 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
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())
}
|