Diameter - pass empty AVP as ^$ in filter

This commit is contained in:
DanB
2016-04-06 10:59:05 +02:00
parent 14ac02f684
commit e5c05ff192
2 changed files with 12 additions and 0 deletions

View File

@@ -287,6 +287,11 @@ func passesFieldFilter(m *diam.Message, fieldFilter *utils.RSRField, processorVa
if err != nil {
return false, 0
}
if len(avps) == 0 { // No AVP found in request, treat it same as empty
if fieldFilter.FilterPasses("") {
return true, -1
}
}
for avpIdx, avpVal := range avps { // First match wins due to index
if fieldFilter.FilterPasses(avpValAsString(avpVal)) {
return true, avpIdx

View File

@@ -473,3 +473,10 @@ func TestCCRAsSMGenericEvent(t *testing.T) {
t.Errorf("Expecting: %+v, received: %+v", eSMGEv, rSMGEv)
}
}
func TestPassesFieldFilter(t *testing.T) {
m := diam.NewRequest(diam.CreditControl, 4, nil) // Multiple-Services-Credit-Control>Rating-Group
if pass, _ := passesFieldFilter(m, utils.ParseRSRFieldsMustCompile("Multiple-Services-Credit-Control>Rating-Group(^$)", utils.INFIELD_SEP)[0], nil); !pass {
t.Error("Does not pass")
}
}