mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2026-02-11 00:45:39 +08:00
增加CC防护相关API定义、配置
This commit is contained in:
@@ -4,13 +4,10 @@ package shared_test
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
||||
"github.com/iwind/TeaGo/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestURLPattern_Match(t *testing.T) {
|
||||
var a = assert.NewAssertion(t)
|
||||
|
||||
type unitTest struct {
|
||||
patternType string
|
||||
pattern string
|
||||
@@ -55,6 +52,24 @@ func TestURLPattern_Match(t *testing.T) {
|
||||
url: "https://example.com",
|
||||
result: false,
|
||||
},
|
||||
{
|
||||
patternType: "wildcard",
|
||||
pattern: "https://example.com",
|
||||
url: "https://example.com",
|
||||
result: true,
|
||||
},
|
||||
{
|
||||
patternType: "wildcard",
|
||||
pattern: "/hello/world",
|
||||
url: "https://example-test.com/hello/world",
|
||||
result: true,
|
||||
},
|
||||
{
|
||||
patternType: "wildcard",
|
||||
pattern: "/hello/world",
|
||||
url: "https://example-test.com/123/hello/world",
|
||||
result: false,
|
||||
},
|
||||
{
|
||||
patternType: "regexp",
|
||||
pattern: ".*",
|
||||
@@ -94,6 +109,9 @@ func TestURLPattern_Match(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
a.IsTrue(p.Match(ut.url) == ut.result)
|
||||
var b = p.Match(ut.url) == ut.result
|
||||
if !b {
|
||||
t.Fatal("not matched pattern:", ut.pattern, "url:", ut.url)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user