Переглянути джерело

more test cases for router config

Darien Raymond 8 роки тому
батько
коміт
661c0fc237
1 змінених файлів з 24 додано та 0 видалено
  1. 24 0
      app/router/condition_test.go

+ 24 - 0
app/router/condition_test.go

@@ -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,
+				},
 			},
 		},
 	}