more test cases for router config

pull/299/merge
Darien Raymond 2017-05-17 21:46:57 +02:00
parent 06d4c37889
commit 661c0fc237
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
1 changed files with 24 additions and 0 deletions

View File

@ -74,6 +74,10 @@ func TestRoutingRule(t *testing.T) {
Value: "google.com",
Type: Domain_Domain,
},
{
Value: "^facebook\\.com$",
Type: Domain_Regex,
},
},
},
test: []ruleTest{
@ -93,6 +97,18 @@ func TestRoutingRule(t *testing.T) {
input: proxy.ContextWithTarget(context.Background(), net.TCPDestination(net.DomainAddress("www.google.com"), 80)),
output: true,
},
ruleTest{
input: proxy.ContextWithTarget(context.Background(), net.TCPDestination(net.DomainAddress("facebook.com"), 80)),
output: true,
},
ruleTest{
input: proxy.ContextWithTarget(context.Background(), net.TCPDestination(net.DomainAddress("www.facebook.com"), 80)),
output: false,
},
ruleTest{
input: context.Background(),
output: false,
},
},
},
{
@ -125,6 +141,10 @@ func TestRoutingRule(t *testing.T) {
input: proxy.ContextWithTarget(context.Background(), net.TCPDestination(net.ParseAddress("2001:0db8:85a3:0000:0000:8a2e:0370:7334"), 80)),
output: true,
},
ruleTest{
input: context.Background(),
output: false,
},
},
},
{
@ -142,6 +162,10 @@ func TestRoutingRule(t *testing.T) {
input: protocol.ContextWithUser(context.Background(), &protocol.User{Email: "love@v2ray.com"}),
output: false,
},
ruleTest{
input: context.Background(),
output: false,
},
},
},
}