mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-14 12:49:54 +05:00
Diameter - pass empty AVP as ^$ in filter
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user