-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathrule_test.go
More file actions
57 lines (50 loc) · 1.3 KB
/
rule_test.go
File metadata and controls
57 lines (50 loc) · 1.3 KB
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
50
51
52
53
54
55
56
57
package main
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestFqdnRule_Matches(t *testing.T) {
ta := assert.New(t)
rule := &FQDNRule{
RuleImpl{
expression: "www.google.com",
},
}
ta.True(rule.Matches("www.google.com"))
ta.True(rule.Matches("www.google.com."))
ta.False(rule.Matches("www.google1.com"))
rule.expression = "www.google.com."
ta.True(rule.Matches("www.google.com"))
ta.True(rule.Matches("www.google.com."))
ta.False(rule.Matches("www.google1.com"))
}
func TestPrefixRule_Matches(t *testing.T) {
ta := assert.New(t)
rule := &PrefixRule{
RuleImpl{
expression: "www.google",
},
}
ta.True(rule.Matches("www.google.com"))
ta.True(rule.Matches("www.google"))
ta.False(rule.Matches("www.google1.com"))
rule.expression = "www.google."
ta.True(rule.Matches("www.google.com"))
ta.True(rule.Matches("www.google"))
ta.False(rule.Matches("www.google1.com"))
}
func TestSuffixRule_Matches(t *testing.T) {
ta := assert.New(t)
rule := &SuffixRule{
RuleImpl{
expression: "google.com",
},
}
ta.True(rule.Matches("www.google.com"))
ta.True(rule.Matches("google.com"))
ta.False(rule.Matches("www.higoogle.com"))
rule.expression = ".google.com"
ta.True(rule.Matches("www.google.com"))
ta.True(rule.Matches("google.com"))
ta.False(rule.Matches("www.higoogle.com"))
}