Merge pull request #984 from slingamn/issue983_bancomp

fix #983
This commit is contained in:
Shivaram Lingamneni
2020-05-05 22:27:00 -07:00
committed by GitHub
2 changed files with 30 additions and 1 deletions
+1 -1
View File
@@ -452,7 +452,7 @@ func (set *UserMaskSet) setRegexp() {
set.RUnlock()
if index > 0 {
expr := "^" + strings.Join(maskExprs, "|") + "$"
expr := "^(" + strings.Join(maskExprs, "|") + ")$"
re, _ = regexp.Compile(expr)
}
+29
View File
@@ -27,3 +27,32 @@ func BenchmarkGenerateBatchID(b *testing.B) {
session.generateBatchID()
}
}
func TestUserMasks(t *testing.T) {
var um UserMaskSet
if um.Match("horse_!user@tor-network.onion") {
t.Error("bad match")
}
um.Add("_!*@*", "x", "x")
if !um.Match("_!user@tor-network.onion") {
t.Error("failure to match")
}
if um.Match("horse_!user@tor-network.onion") {
t.Error("bad match")
}
um.Add("beer*!*@*", "x", "x")
if !um.Match("beergarden!user@tor-network.onion") {
t.Error("failure to match")
}
if um.Match("horse_!user@tor-network.onion") {
t.Error("bad match")
}
um.Add("horse*!user@*", "x", "x")
if !um.Match("horse_!user@tor-network.onion") {
t.Error("failure to match")
}
}