Diameter - completing field templates for individual messages

This commit is contained in:
DanB
2016-02-24 14:07:08 +01:00
parent b039693102
commit f3e5f0bfde
6 changed files with 96 additions and 14 deletions

View File

@@ -166,6 +166,9 @@ func (rsrFltr *RSRFilter) Pass(val string) bool {
if rsrFltr.filterRule[:1] == REGEXP_PREFIX {
return rsrFltr.fltrRgxp.MatchString(val) != rsrFltr.negative
}
if rsrFltr.filterRule == "^$" { // Special case to test empty value
return len(val) == 0 != rsrFltr.negative
}
if rsrFltr.filterRule[:1] == MatchStartPrefix {
return strings.HasPrefix(val, rsrFltr.filterRule[1:]) != rsrFltr.negative
}

View File

@@ -341,4 +341,14 @@ func TestRSRFilterPass(t *testing.T) {
if fltr.Pass("CGRateS") {
t.Error("Passing!")
}
fltr, err = NewRSRFilter("^$") // Empty value
if err != nil {
t.Error(err)
}
if fltr.Pass("CGRateS") {
t.Error("Passing!")
}
if !fltr.Pass("") {
t.Error("Not passing!")
}
}